Nginx WebSockets 代理实现 补记

之前 Nginx WebSockets 代理实现

Nginx WebSockets 代理实现

对nginx实现WebSockets做了最基本的方法说明,然而实际运行会发现,如果域名的IP经常变动,该方法会造成更新不及时的问题。

示例配置:

map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server 192.168.100.10:8010 max_fails=0 fail_timeout=0;
}
server {
listen 8020;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
}

未经允许不得转载:阿藏博客 » Nginx WebSockets 代理实现 补记

赞 (0) 打赏