Nginx教程

webSocket nginx 反向代理配置

本文主要是介绍webSocket nginx 反向代理配置,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.http中配置 $connection_upgrade 否则报错

http {
	   map $http_upgrade $connection_upgrade {
	    default upgrade;
	    ''      close;
	}
}

2.具体配置部分:

 location /message {
        proxy_pass http://127.0.0.1:8100;   需要代理的后端ip
        proxy_read_timeout 300s;
        proxy_send_timeout 300s;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        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 $connection_upgrade;
    }
这篇关于webSocket nginx 反向代理配置的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!