使用nginx的开发版本(1.3.12)。 在我启用网站的相关文件中:
upstream twisted { server 127.0.0.1:8088; } server { listen 80; ## listen for ipv4 server_name *.clurn.co.uk clurn.co.uk; access_log /var/log/nginx/clurn.co.uk.access.log; location / { root /var/www/clurn.co.uk; 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; } [...snip...] }
与nginx网站上的例子不同的是升级的资本u,它似乎是高速公路和/或txWS实例正确识别websocket所必需的(我不记得它是哪个atm)。
现在,如果我通过服务器上的127.0.0.1:8088访问websockets,那么它似乎工作,但如果我通过127.0.0.1/websockets访问它不,所以必须有错误的编组数据包通过nginx。
如果我运行netcat -l -p 8088而不是Twisted websocket后端,我可以看到,如果通过nginx或直接访问请求是相同的(原本他们不是,但更改“升级”为“升级”作出标题线路Connection: Upgrade相同),所以这部分代理正确。
但是,如果我telnet到127.0.0.1:8088和127.0.0.1/websocket ,复制并粘贴正确的请求,我得到一个直接的127.0.0.1:8088响应,而不是127.0.0.1/websocket 。 我在做什么错了,我怎么能设置它允许双方的websockets?
我认为问题是缓冲。 组:
proxy_buffering off;
里面的websocket位置configuration。