这样的配置将起作用:
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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
您需要以root用户身份运行Nginx才能监听端口80。现在您可以使用浏览器访问“ localhost”。有关Nginx和websockets的更多信息,请参见此处。
| 归档时间: |
|
| 查看次数: |
3366 次 |
| 最近记录: |