nginx 支持websocket 转发

在http模块加上

map $http_upgrade $connection_upgrade {
default upgrade;
” close;
}

 

在server模块,加上

upstream logger{
ip_hash;
server 127.0.0.1:81;
server 127.0.0.1:82;
}

 

location / {
proxy_pass http://logger;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;

}

 

编译nginx入常即可

 

Leave a Reply