NGINX return 405 Not Allowed with POST method

99封情书 提交于 2021-02-10 18:10:37

问题


I have this default.conf:

server {
        listen  443 ssl;
        root /etc/nginx/json/;
        server_name    myserver.com;
        ssl_certificate /etc/ssl/certs/server.crt;
        ssl_certificate_key     /etc/ssl/private/server.key;
        ssl_protocols   TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers     HIGH:!aNULL:!MD5;
        location /platform/enabler/iam/token/generate/1.0.0
        {
                alias  /etc/nginx/json/generateToken.json;
        } }

calling the API with GET method the response is correct. calling the API with POST method the response is:

<html>
<head><title>405 Not Allowed</title></head>
<body bgcolor="white">
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx/1.14.2</center>
</body>
</html>

Please, could you help me?


回答1:


You can add the following line to your config to make nginx serve the POST requests with static files:

error_page 405 =200 $uri;


来源:https://stackoverflow.com/questions/62431038/nginx-return-405-not-allowed-with-post-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!