Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

Using the development version of nginx (1.3.12). In my relevant file under sites-enabled:

upstream twisted {

server {  

    listen   80; ## listen for ipv4  

    server_name  *;  

    access_log  /var/log/nginx/;  

    location / {  
            root   /var/www/;  
            index  index.html index.htm;  


    location /websocket {  
            proxy_pass http://twisted;  
            proxy_http_version 1.1;  
            proxy_set_header Upgrade $http_upgrade;  
            proxy_set_header Connection "Upgrade";  

    location /websocket/server {  
            deny all;  


Only difference from the example on nginx's site is the capital u on upgrade, which seemed to be necessary for the Autobahn and/or txWS instances to recognise the websockets correctly (I can't remember which one it was atm).

Now, if I access the websockets via on the server, then it appears to work, but if I access it via it doesn't, so there has to be something wrong with the marshalling of the packets via nginx.

If I run netcat -l -p 8088 instead of the Twisted websocket backend, I can see that the requests are identical if accessed via nginx or directly (originally they weren't, but changing the "upgrade" to "Upgrade" made the header line Connection: Upgrade the same), so this part is proxying correctly.

However, if I telnet into and, copying and pasting the correct request, I get a response with the direct, and do not with the What am I doing wrong, and how can I set it up to allow websockets on both sides?

share|improve this question /websockets and / are different requests. Is it still working when you request /websockets? – VBart Feb 28 '13 at 20:39
Did you solve this? I'm getting pretty much the same behavior. I was able to successfully proxy through nginx with a websocket-only server (all the set_headers being at the root level of the server config), but get no responses otherwise. – outofculture Mar 22 '13 at 18:11
up vote 2 down vote accepted

I think the problem is buffering. Set:

proxy_buffering off;

inside the websocket location config.

share|improve this answer
Unfortunately I no longer have the setup so can't check. But it sounds like if it solved your issue (if it were the same) then it may as well be marked as correct. – socksy Nov 8 '13 at 3:12

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.