我有以下配置来设置 django应用程序通过nginx上的uwsgi提供 upstream node{ server 127.0.0.1:8081 max_fails=1 fail_timeout=20s;}server { listen 8000 default_server ssl; server_name bla.bla; ssl_certificate path; ssl_certificat
upstream node{ server 127.0.0.1:8081 max_fails=1 fail_timeout=20s; } server { listen 8000 default_server ssl; server_name bla.bla; ssl_certificate path; ssl_certificate_key path; location /serve { proxy_pass http://node; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_cache_bypass 1; proxy_no_cache 1; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-NginX-Proxy true; proxy_connect_timeout 2s; } location / { include uwsgi_params; uwsgi_pass unix:///var/uwsgi/sel.sock; } }
我有一个nodejs服务器,在端口8081上运行websocket服务器
var WebSocketServer = require('ws').Server , wss = new WebSocketServer({ port: 8081, path: "/serve" });
现在,当我使用html页面访问websocket服务器时
var websocket = new WebSocket("wss://host:8081/serve"); // works var websocket = new WebSocket("wss://host:8000/serve"); // doesn't work get 504 error
我究竟做错了什么?任何人都可以指出我的错误,并显示一个正确配置它的指针.
编辑:我的nginx版本是nginx版本:nginx / 1.4.6(Ubuntu)
wss假定使用TLS加密的WebSocket连接.如果wss:// host:8081有效,则node.js将侦听加密连接.但是您已经为TLS终止配置了nginx并代理了未加密的数据.