如何允许在Nginx上使用HTTP方法

如何允许在Nginx上使用HTTP方法,http,nginx,post,methods,get,Http,Nginx,Post,Methods,Get,我正在尝试传递一些HTTP方法。Post和Get方法也在工作,但当我尝试使用Head方法时,我总是得到这个输出 405 Method Not Allowed Connection: close Date: Wed, 29 Jan 2020 08:37:05 GMT Server: Kestrel Allow: GET Client-Date: Wed, 29 Jan 2020 08:37:05 GMT Client-Peer: 127.0.0.1:5000 Client-Response-Num

我正在尝试传递一些HTTP方法。Post和Get方法也在工作,但当我尝试使用Head方法时,我总是得到这个输出

405 Method Not Allowed
Connection: close
Date: Wed, 29 Jan 2020 08:37:05 GMT
Server: Kestrel
Allow: GET
Client-Date: Wed, 29 Jan 2020 08:37:05 GMT
Client-Peer: 127.0.0.1:5000
Client-Response-Num: 1
我在互联网上的研究不起作用。我怎样才能解决这个问题

这是我的配置文件

server {
listen        80;
server_name   xtest.com *.xtest.com;
    location / {
        proxy_pass         http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
}

    location ~ ^/api/(.*)$ {
        proxy_pass       http://localhost:5000/$1;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }

     add_header Allow "GET, POST, HEAD" always;
     if ( $request_method !~ ^(GET|POST|HEAD)$ ) {
        return 405 http://localhost:5000;
     }
谢谢你的帮助


关于,

从回复来看,它似乎来自Kestrel服务器,而不是Nginx。谢谢@RichardSmith,现在我确定了为什么我仍然收到错误。