nginx可以代理websocket以及负载均衡, 代理https证书,websocket服务处理好业务就好了。
http {
upstream WebSocket {
server 127.0.0.1:8080;
}
server {
listen 9988;
server_name localhost;
location ^~ /ws {
proxy_pass http://WebSocket;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}