nginx
可以转发websocket
请求,具体配置如下1
new Websocket('ws://127.0.0.1/ws/123456')
1
2
3
4
5
6location /ws/ {
proxy_pass http://backend:8887;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}这么配置会将请求转发至
ws://backend:8887/ws/123456
如若转发时不想带上前端的前缀,可以这么配置
1
axios.get('http://ip/prod-api/get')
1
2
3location /prod-api/{
proxy_pass http://backend:8887/;
}这么配置会将请求转发至
http://backend:8887/get