question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

can not proxy from nginx

See original GitHub issue

Issue details

I want to proxy localhost:3001 from nginx, but it doesn't work.

(sorry, I’m not good for English, I’m Chinese)

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

  • Browsersync [ 2.12.8 ]
  • Node [ 5.10.1 ]
  • Npm [ 3.8.3 ]

Affected platforms

  • linux
  • windows
  • OS X

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • Nginx

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

  • my plan for the development environment
  firefox <------> nginx (rewrite path, proxy to api) <---(proxy)---> browser-sync (gulp auto build website files)
  • browser-sync
browserSync.init({
    socket: {
        path: '/browser-sync/socket.io',
        clientPath: '/browser-sync',
        namespace: '/browser-sync',
        domain: 'testbs.org'
    },
    server: 'public',
    open: true
});
  • nginx
server {

    listen 80;
    server_name testbs.org;

    ......

    # BrowserSync
    location / {
        proxy_pass http://localhost:3000/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

    # BrowserSync websocket
    location /browser-sync/socket.io/ {
        proxy_pass http://localhost:3001/browser-sync/socket.io/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }

    ......

}
  • Browser Console
GET http://testbs.org/browser-sync/socket.io/?EIO=3&transport=polling&t=LJ9VN7W
    504 Gateway Time-out 1m browser...12.8.js (line 1)

GET http://testbs.org/browser-sync/socket.io/?EIO=3&transport=polling&t=LJ9VSOA
    504 Gateway Time-out 1m browser...12.8.js (line 1)

GET http://testbs.org/browser-sync/socket.io/?EIO=3&transport=polling&t=LJ9VY2g
    504 Gateway Time-out 1m browser...12.8.js (line 1)

1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

5reactions
realmxcommented, Jun 2, 2016

@adambuczek my issue has been resolved by myself😀 let me show you about my configuration:

  • nginx
server_name                         test.local.dev
location / {
    # BrowserSync
    proxy_pass                      http://localhost:3010;
    proxy_set_header                Upgrade $http_upgrade;
    proxy_set_header                Connection "Upgrade";
}
  • gulp
browserSync.init({
    server: 'public',
    port: 3010,
    ui: {
        port: 3011,
        weinre: {
            port: 3012
        }
    },
    open: false
});

and now, i can do refresh by the test.local.dev, didn’t use the localhost😃

1reaction
iDVBcommented, Mar 11, 2017

@realmx yes that describes how BrowserSync works.

However, it does not explain why when I run it without nginx it is about 5x faster then if Nginx is implemented. I would expect it to be negligibly slower with nginx, but not 5x slower. It’s IMHO, it’s unusable due to this length of delay.

Read more comments on GitHub >

github_iconTop Results From Across the Web

proxy - nginx simple proxy_pass to localhost not working
If I ssh to the machine and run curl http://127.0.0.1:3000/ , I get the desired result (and eventually I ran that server on...
Read more >
Nginx/proxy not working properly - Server Fault
the problem is that Nginx is giving bad gateway for all proxied requests and timeout for the direct ip access. proxy conf :...
Read more >
NGINX Reverse Proxy Configuration and Troubleshooting
In normal reverse proxy configuration, NGINX act as a TLS terminator, it will not pass TLS connection to original server. In some scenario...
Read more >
NGINX Reverse Proxy | NGINX Plus - NGINX Documentation
Configure NGINX as a reverse proxy for HTTP and other protocols, with support for modifying request headers and fine-tuned buffering of responses.
Read more >
Why is reverse proxy is not working with nginx? - DigitalOcean
I have spun up a Fedora box, and am running a golang server at port 8080. I am trying to setup nginx reverse...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found