nginx转发post put变成get
现象:
使用nginx转发请求,如果请求的类型是post或者put类型,会自动转成get类型。
解决方法:
location不要以"/"结尾。
修改前:
location ^~ /user/infos/ {
proxy_pass http://localhost:80/user/infos/;
}
修改后:
location ^~ /user/infos {
proxy_pass http://localhost:80/user/infos;
}
完整配置:
location ^~ /user/infos {
proxy_pass http://localhost:80/user/infos;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}