websocket-nginx反向代理

nginx反向代理easyswoole的http和websocket

server {
    root /var/www/es;
    server_name esapi.test;
    # 代理http
    location / {
        proxy_http_version 1.1;
        proxy_set_header Connection "keep-alive";
        proxy_set_header X-Real-IP $remote_addr;
        if (!-f $request_filename) {
             proxy_pass http://192.168.3.67:9501;
        }
        # 代理websocket就靠下面两行
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection upgrade;
    }
}

相关资料

官方文档参考

发表评论