location ^~/apiservice/ {
proxy_pass http://test.net/apiservice/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Connection keep-alive;
proxy_set_header Keep-Alive 600;
keepalive_timeout 600;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
该配置 访问 localhost/apiservice/user/add 会自动映射到 http://test.net/apiservice/user/add
静态资源配置
location / {
try_files $uri $uri/ /index.html;
alias /data/app/crm/web/CRM-FE/dist/;
index index.html index.htm;
}
alias:制定路径
try_files:vue的路由,在刷新页面的时候不会出现404