用nginx上了個前端項目,踩了路徑的坑,記錄一下:
server {
listen 2077;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
# 例如:你前端的請求路徑是這樣的 /api/v1/getData
# ^~ /api/ 匹配以‘/api/’開頭的請求,請求會被拼接成:http://10.10.10.10:8080/v1/getData
location ^~ /api/ {
proxy_pass http://10.10.10.10:8080/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}