若依 前后端分离部署 Nginx 配置
Nginx 配置
仅供参考:
server
{
listen 80;
server_name 127.0.0.1;
charset utf-8;
# index index.php index.html index.htm default.php default.htm default.html;
# 项目配置信息
# 添加 vue 路由跳转
location / {
# vue 打包后的文件目录地址
root /www/wwwroot/dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
# 后端 API 代理
location /prod-api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 填写的内容要与若依前端代码中的target中的地址一致
proxy_pass http://127.0.0.1:8080/;
proxy_connect_timeout 6000s;
proxy_read_timeout 6000s;
proxy_send_timeout 6000s;
}
location /dev-api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 填写的内容要与若依前端代码中的target中的地址一致
proxy_pass http://127.0.0.1:8080/;
proxy_connect_timeout 6000s;
proxy_read_timeout 6000s;
proxy_send_timeout 6000s;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}