Skip to content

Subdirectory doesn't work for socket.io path #1707

Closed
@demyxco

Description

@demyxco

Issue details

I have BrowserSync as a Docker container on a remote server with Traefik as the reverse proxy, it works well with HTTPS and using subdomains. I want to move the access URL and UI to a subdomain to reduce SSL cert requests to LetsEncrypt but I am having some trouble. I've tried everything from changing the socket's namespace, domain, path, and clientPath. It either 502s or 404s, even tried some NGINX magic, but still no dice. The setup I had plan for was this:

Steps to reproduce/test case

I'm not sure how others environments are setup but you can just simply try changing the socket.io path and see if you can have it configured on a subdirectory (domain.tld/sub/browser-sync/socket.io).

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.26.7 ]
  • Node [ v12.4.0 ]
  • Npm [ 6.9.0 ]

Affected platforms

  • [✅] linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (please specify which)

Browsersync use-case

  • [✅] API
  • Gulp
  • Grunt
  • [✅] CLI

If CLI, please paste the entire command below

docker run -d --rm \
--name "$DEMYX_APP_COMPOSE_PROJECT"_bs \
--net demyx \
--volumes-from "$DEMYX_APP_WP_CONTAINER" \
-l "traefik.enable=true" \
-l "traefik.bs.frontend.rule=Host:${DEMYX_APP_DOMAIN}; PathPrefixStrip: /demyx-bs/" \
-l "traefik.bs.port=3000" \
-l "traefik.ui.frontend.rule=Host:${DEMYX_APP_DOMAIN}; PathPrefixStrip: /demyx-ui/" \
-l "traefik.ui.port=3001" \
demyx/browsersync start \
--config "/demyx/bs.js" \
--proxy "$DEMYX_APP_WP_CONTAINER" \
--files "/var/www/html/**/*" \
--port 3000 \
--ui-port 3001 

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

bs.js

module.exports={ 
    script: { 
        domain: '/demyx-bs' 
    }, 
    socket: { 
        domain: '/demyx-bs', 
        path: '/demyx-bs/browser-sync/socket.io', 
        clientPath: '/demyx-bs/browser-sync', 
        namespace: '/demyx-bs/browser-sync' 
    } 
};

nginx.conf

upstream bs {
    server 127.0.0.1:3000;
}

location /demyx-bs/browser-sync/socket.io/ {
    proxy_pass http://bs/demyx-bs/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions