第二天发现以上配置无法使用,于是给访路径加上/,然后更改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
https://www.jianshu.com/p/89201a82528d
https://www.oschina.net/question/54100_30402