第二天發(fā)現(xiàn)以上配置無法使用,于是給訪路徑加上/,然后更改nginx配置為
location /api{
proxy_pass http://test;
rewrite /api/(.+)$ /$1 break;
proxy_set_header Host $proxy_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass_request_headers on;
}
參考:
https://www.cnblogs.com/lemon-le/p/7800879.html
http://www.reibang.com/p/89201a82528d
https://www.oschina.net/question/54100_30402