BrowserSync / browser-sync

Keep multiple browsers & devices in sync when building websites. https://browsersync.io
https://discord.gg/2d2xUThp
Apache License 2.0
12.17k stars 755 forks source link

docker proxy and ssh tunnel? #1855

Open tamis-laan opened 3 years ago

tamis-laan commented 3 years ago

I'm using browser-sync in proxy mode inside a docker container, trying to then move through a ssh reverse tunnel.

  1. Docker container where the server is running on 3000 and browser-sync proxies it to port 4000.
      browser-sync start 
        --files './build/client' 
        --proxy localhost:3000 
        --port 4000
  2. Port 4000 on the docker container is exposed to port 4000 on my local machine.
  3. Next this is tunneled through a reverse tunnel from 4000 on my local machine to 4000 on my server.

My server then redirects trafic from mycoolwebsite.xyz to port 4000 which is then tunneled back to the docker container.

This works, except for the browser-sync websocket which is trying to connect back too localhost:4000 producing the following error:

GET http://localhost:4000/browser-sync/socket.io/?EIO=3&transport=polling&t=NYIrsh6 net::ERR_CONNECTION_REFUSED

It should connect back to mycoolwebsite.xyz and go through the reverse tunnel instead :-(

tamis-laan commented 3 years ago

What I don't understand is that the front end browser-sync script doesn't use window.location.origin for the websocket to connect back?

Then it wouldn't try to connect to localhost:4000.

tamis-laan commented 3 years ago

No way to get his working?