一直报405错误,是因为location /prod-api/ 这个/prod-api/ 的问题,之前在网上看不知道这是什么,见别人的代码就换掉了,应该把这个地方换成与你的前端对应的路径前缀。
server {
listen 80;
server_name localhost;
location / {
root C:/Users/29658/Desktop/nginx-1.12.2/html/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html; #解决页面刷新404
}
location /prod-api/{
#175.7.59.163
rewrite ^/prod-api/(.*)$ /$1 break;
proxy_pass http://localhost:8800;
proxy_read_timeout 1200;
proxy_set_header Host $HOST;
}
}