屏蔽指定路徑
location /user {
deny all;
}
location /order {
deny all;
}
指定路徑轉發
前匹配:只匹配路徑以/report/
開頭的URL;
location ^~ /report/ {
proxy_pass http://127.0.0.1:8080;
}
/report/page-a
/report/page-b.do
/report/page-c.html
精確匹配
location = /user/info {
proxy_pass http://127.0.0.1:8080;
}
/user/info
靜態資源映射
location ^~ /static/vue/ {
root /app/web/;
}
/static/vue/index.html -> /app/web/static/vue/index.html
location ^~ /assets/ {
root /app/web/static/vue;
}
/assets/css/main.css -> /app/web/static/vue/assets/css/main.css
接口轉發
location /api/ {
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:8080/;
}
注意後面的斜線