NGINX 返回 405 Not Allowed with POST 方法 [英] NGINX return 405 Not Allowed with POST method

查看:163
本文介绍了NGINX 返回 405 Not Allowed with POST 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个 default.conf:

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;
        } }

使用 GET 方法调用 API 响应是正确的.使用 POST 方法调用 API 的响应是:

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>

拜托,你能帮我吗?

推荐答案

您可以将以下行添加到您的配置中,以使 nginx 为带有静态文件的 POST 请求提供服务:

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

error_page 405 =200 $uri;

这篇关于NGINX 返回 405 Not Allowed with POST 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆