server {
listen 80;
root /www/hyperf-admin/;
server_name www.51maihuo.cn;
location / {
proxy_pass http://127.0.0.1:9501;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#此处根据websocket的请求路由进行配置
location /im {
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X_Forward_For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:9502;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
转自 知乎专栏