-
Notifications
You must be signed in to change notification settings - Fork 757
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
Socket port not accessible #505
Comments
Interesting! I'd be very interested in making BrowserSync work with Docker - so if you could point in the the right direction re: getting setup or a tutorial that would be great. |
Greetings, I'm trying to make Browser-sync work from a docker container as well, with no luck. So
|
Hi, I'm trying to make browser-sync work with Docker as well. If you want a quick starting point, you can use the public docker image I'm working on: https://registry.hub.docker.com/u/ustwo/browser-sync My problem seems to be a sort-of loop:
|
Hi, I created https://github.com/ustwo/docker-browser-sync to test use cases with browser-sync inside Docker. |
As far as the internal/external port issue, I've actually just started seeing this issue after upgrading to the latest version of browsersync. Everything used to work correctly since Browsersync would use the location hostname + port from the browser to create the socket.io path, but now after b2fa337 it seems now will use #{location.hostname}:#{port} which isn't correct in my case. I use NGINX in another docker container to proxy to the Browsersync docker container so the ports that Browsersync aren't going to be the external one. Basically, if Browsersync reverts back to using location.host instead of location.hostname I think it should work. |
Is there any workaround available how to fix this? |
👍 |
Have any of you got this running? Would love to have the randomized host ports. |
+1 |
Although a very old issue I spent a considerable amount of time trying to see the issue and trying potential fixes. I think I narrowed it down to different commits around work done on #625. And probably other related ones. I believe that when the issue above was done something was not properly thought and some other things were wrongly replaced. First when you set a proxy browser-sync is setting it to "snippet" mode and I believe that's wrong. Also, you can set proxy with:
Which apparently is intended to also proxy the webservice, but then on some other places it feels as the same setting is used in the opposite way. While I think I could submit a PR I am also not sure if I will cover or be able to test all use cases (like the one on #625) and there seems to be little activity in terms of PRs in the module, so I tried to come up with a workaround. While probably not great (still neat and useful) this is what I did and it does work.
I am setting the local client javascript back to what it was back then like what's mentioned above. The proxyRes function might not be needed but I am also documenting it and it's an useful way of allowing POSTs (forms) to work. It's possible that by doing this the intended fix for #625 is lost, so if you have other WS going through the proxy, this might not be the best way of doing it or you might need to do something further. |
I have BrowserSync running in a docker container. Docker maps a random external port to the exposed internal port.
For BrowserSync, this means that the websocket cannot be reached when using the UI. The script used by the UI generates a URL which points at
port
setting, but the script is being run in a browser outside of the container context.Example: port 3000 is mapped to 49300 and port 3001 (UI) is mapped to 49301. I visit http://site.dev:49301/ in my browser, the UI page loads. The UI scripts tries to connect to site.dev:3000, which fails.
I'm not really sure how to go about fixing this, as by design, the software running inside a container doesn't know which port the host has exposed.
The text was updated successfully, but these errors were encountered: