当vue和api使用相同的端口时的配置方法(这是通过redis实现redis共享的)
##静态文件配置
location / {
root html;
try_files $uri $uri/ @router;
index index.html index.htm;
}
## 接口配置
location /api/ {
proxy_pass http://127.0.0.1:6609/api/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_hide_header Server;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 10;
proxy_send_timeout 10;
proxy_read_timeout 10;
proxy_intercept_errors on;
proxy_buffering off;
}
##websocker配置
location /api/ws/ {
proxy_pass http://127.0.0.1:6609/api/ws/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
网友评论