我有一个Spring Boot应用程序,该应用程序将POST请求发送到端口8090上服务器上的端点。我的Java控制器是:
@RequestMapping(value="/decision", method = POST)
@ResponseBody
public void setDecision(HttpEntity<String> httpEntity, @RequestHeader("Authorization") String auth) throws Exception {
// controller implementation
}
我在SSL配置中使用了nginx,它可以在default-ssl文件中代理对端口8090的请求:
location /my_endpoint
{
auth_basic off;
proxy_pass http://localhost:8090;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
当我与邮递员发送请求并打开nginx的访问日志时,我看到以下输出:
My.IP.Address - [31/Aug/2018:08:49:59 +0200] "POST /my_endpoint HTTP/1.1" 301 185 "-" "PostmanRuntime/7.1.1"
My.IP.Address - [31/Aug/2018:08:50:00 +0200] "GET /my_endpoint HTTP/1.1" 405 163 "http://MyServer/my_endpoint" "PostmanRuntime/7.1.1"
所以我不明白为什么我发送POST请求时nginx使其成为GET请求。