-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allows separating public host name from server IP address binding #768
Conversation
@@ -23,7 +23,7 @@ export default function start(options){ | |||
|
|||
const { | |||
port, | |||
host, | |||
bind: bindIp = "0.0.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this I don't even. :squint:
Cool inline default syntax. Shouldn't defaults go in defaultOptions.js
, though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't defaults go in defaultOptions.js, though?
I... um. Yes, probably. Will do.
.option("bind", { | ||
describe: "IP address to bind to. Default: 0.0.0.0 (any)", | ||
type: "string", | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we call it bindIp
internally to disambiguate, maybe the CLI option should be --bind-ip
, too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do.
This makes a lot of sense. So generally we would want The description in
Should probably update that. ... is this a breaking change? 🤔 |
b2f617e
to
931f238
Compare
I was under the assumption that that is how it was being used already (if it's used at all?), since whatever you put there seems to end up in the URLs for static content when you're developing.
Will update to 'the public host name used to construct URLs for static content'?
I think it is, technically, though the broken case I can come up with seems vanishingly unlikely right now. If my understanding is correct, the default behavior now will be to bind to any (or maybe "all" is more correct?) IP address on the machine were react-server is running, whereas previously, it would bind to whatever IP address the hostname resolved to. If anybody was relying on react-server being bound to a specific interface in production, I think that behavior will change. If foo.com resolves to 1.2.3.4 and bar.com resolves to 2.4.6.8, but both are hosted on the same machine, and both are running react-server, it seems like one of those two servers won't start up without passing |
I'm suddenly confused. Wondering how react-server.io works a all with |
I thought (though maybe I'm misremembering?) that I might be totally confused about this, it's been a while. |
@aickin That's correct. The trigger for this change was that we're passing the value of |
@gigabo not sure, but trying to figure it out. My pet theory (with no hard evidence) is that the answer rhymes with "docker" or "nginx". |
I get that, I'm just confused because this PR seems to me like it deletes |
It's still used in options.outputUrl = jsUrl || `${httpsOptions ? "https" : "http"}://${host}:${jsPort}/`; |
@gigabo Got it. That's what I was missing. And Thanks for listening to the mumblings of a frequently confused man. ;) |
@aickin Not even going to tell you how long I spent trying to understand that flow this morning. I saw the expected behavior ( |
@roblg best part is: it was probably my doing, and even I couldn't understand it any more! <evil cackle, alternating with sobs> |
The fog is clearing. Turns out the broken behavior being targeted by this PR is a regression introduced relatively recently by #665, which started passing the value of @gigabo turns out that the @SeverS after this PR merges, if you want to bind For those following along at home, there's some additional context in this SO post about what happens to the |
Whoa! Glad you tracked this down before the website horked! Nice investigation, @roblg thanks for fixing this! 🤘 |
Is it safe to merge this at this point? Are we worried about the possibly-breaking part of these changes? |
Yeah, do it! |
I was playing around w/
react-server
in cloud9's IDE (https://c9.io/) and ran into an issue where passing --host
into the server listen (the default behavior ofreact-server-cli
) did the wrong thing. I think the issue is due to cloud9's environment being containers running on a VM, where multiple public hostnames share the same public IP address, and the port that is presented to the container is not the actual physical port on the machine.This PR separates the hostname given for loading resources like JS/CSS from the IP address that the server binds to, defaulting to binding to any IP address.
This fixes the issue for me (after I hand-modify the RequestToPort middleware so that it doesn't assume port 3000 😁) However, container networking isn't necessarily my forte, so if there are other/better ideas on how to fix the issue, I would love to hear them.