nginx的单页面server的配置和rewrite指令的使用
server {
listen 81;
root /home/xxx/wwwdev/orgadmin/dist;
index index.html;
client_max_body_size 200M;
client_body_buffer_size 128K;
location / {
try_files $uri $uri/ @router;
index index.html;
}
location @router {
rewrite ^.*$ /index.html last;
}
location /dev-api {
rewrite ^/dev-api/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:8202;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
}
}