Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I've been following this tutorial, and everything seems to run OK, except for my nginx setup. My node.js application runs on port 1337, varnish runs on port 80, stunnel on 443 and nginx on 8080.

I can reach my app correctly when i specify the port https://example.com:1337 but all I get when visiting https://example.com is a 502 Bad Gateway error.

This is the output of my nginx log:

2012/08/25 14:13:59 [error] 6049#0: *1 no live upstreams while connecting to upstream, client:, server: example.com, request: "GET / HTTP/1.1", upstream: "http://app_example/", host: "example.com"
2012/08/25 14:14:02 [error] 6049#0: *1 upstream prematurely closed connection while reading response header from upstream, client:, server: example.com, request: "GET / HTTP/1.1", upstream: "", host: "example.com"

and this is my nginx config file for that domain:

upstream example.com {

server {
    server_name  example.com;
    listen 8080;
    location / {
            proxy_pass      http://example.com;
            proxy_redirect  off;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

I'm running:

  • Ubuntu 12.04
  • nginx/1.1.19
  • stunnel 4.42
  • varnish-3.0.2
share|improve this question

1 Answer 1

up vote 1 down vote accepted

So first thing.. that link said they are only using nginx for static files and html files for the website. You are trying to proxy nodejs/websockets over nginx.

So why does that website say not to do that? Mainly because websockets are not supported in nginx in a stable release.

Websockets are a 1.1 spec and nginx is only 1.0 spec. Now that said.. you can compile in like tcp_proxy for nginx but just proxy it with varnish like that url pointed out. It does not make a lot of sense to go


just do

varnish -> node

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.