有人可以为我提供Tornado websocket聊天演示的Nginx配置吗?该演示位于/ tornado / demos / websocket下…
解决方法:
像这样的配置将起作用:
events {
worker_connections 1024;
}
http {
upstream chatserver {
server 127.0.0.1:8888;
}
server {
# Requires root access.
listen 80;
# WebSocket.
location /chatsocket {
proxy_pass http://chatserver;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
proxy_pass http://chatserver;
}
}
}
您需要以root身份运行Nginx才能侦听端口80.现在您可以使用浏览器访问“localhost”. More info on Nginx and websockets here.