Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 but all I get when visiting 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:, request: "GET / HTTP/1.1", upstream: "http://app_example/", host: ""
2012/08/25 14:14:02 [error] 6049#0: *1 upstream prematurely closed connection while reading response header from upstream, client:, server:, request: "GET / HTTP/1.1", upstream: "", host: ""

and this is my nginx config file for that domain:

upstream {

server {
    listen 8080;
    location / {
            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
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.