Nginx 配置 ws 代理
# WebSocket代理
location /wsUrl/ {
rewrite ^/wsUrl/(.*)$ /$1 break;
proxy_pass http://192.168.1.100:9890; #这里是http不是ws,不用怀疑,代理的ip和port写ws访问的实际地址
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
http 代理
location ^~ /apis/ {
proxy_set_header X-Forward-For $remote_addr;
proxy_set_header X-real-ip $remote_addr;
proxy_pass http://10.10.9.5:9002/;
}
定位index.html
location / {
try_files $uri $uri/ /index.html;
}
vue 代理只能解决开发环境 不能解决部署环境,所以需要用nginx代理