`
chembo
  • 浏览: 933905 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

nginx 405 Not Allowed

阅读更多
这个错误的原因是:Apache、IIS、Nginx等绝大多数web服务器,都不允许静态文件响应POST请求,否则会返回“HTTP/1.1 405 Method not allowed”错误。

upstream static_backend {
    server localhost:80;
}

server {
    listen 80;

    # ...

    error_page 405 =200 @405;
    location @405 {
        root /srv/http;
        proxy_method GET;
        proxy_pass http://static_backend;
    }
}
分享到:
评论

相关推荐

    Nginx静态文件响应POST请求 提示405错误的解决方法

    <TITLE>405 Method Not Allowed <H1>Method Not Allowed The requested method POST is not allowed for the URL /index.html.<P> <ADDRESS>Apache/1.3.37 Server at www.jb51.net Port 80</ADDRESS> `...

    http请求405错误方法不被允许的解决 (Method not allowed)

    主要介绍了http请求405错误方法不被允许的解决 (Method not allowed),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

    Ngnix 数据接口报405错误问题解决

    全部接口报405 NOT Allowed 错误,如下图所示:   解决问题过程 在网上查了很多,试了几种方案 (1)前端将POST请求更改为GET请求;  (2)nginx配置加上如下代码 :  location / { error_page 405 =200 /...

    Nginx反向代理proxy_cache_path directive is not allowed错误解决方法

    nginx: [emerg] “proxy_cache_path” directive is not allowed here in /etc/nginx/conf.d/default.conf:29 提示意思“proxy_cache_path指令不被允许”,在官网上查找了相关说明,也没有发现问题,最后看应用范围...

    nginx对http method的控制修改方法

    例如,当客户端发送一个POST请求时,如果Nginx配置中没有明确允许该方法,则可能会返回405 Method Not Allowed的状态码。 #### 三、源码级修改步骤 ##### 1. 进入Nginx源码目录 首先,需要获取Nginx的源码包,并...

    Nginx解决转发地址时跨域的问题

    Origin 'null' is therefore not allowed access. 这就是跨域问题。解决方案有不少,比较好的是服务器端配置CORS,但要求服务器端做更改。如果在不需要更改服务器端的情况下解决呢?尤其是需要在

    Nginx跨域设置Access-Control-Allow-Origin无效的解决办法

    nginx 版本 1.11.3 使用大家说的以下配置,验证无效,跨域问题仍然存在 add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow...

    nginx配置引发的403问题解决办法

    2. **404错误的误导**:尝试访问`/usr/local/nginx/html1/a.txt`时,错误代码变成了404 Not Found。这看起来矛盾,但实际上,这是因为虽然`www.requesturi.com`的配置不存在,但Nginx默认使用了`www.zhuye.com`的...

    nginx经过多层代理后获取真实来源ip过程详解

    问题 nginx取 $remote_addr 当做真实ip,而事实上,$http_X_Forwarded_For 才是用户真实ip,$remote_addr只是代理上一层的地址 ...nginx: [emerg] unknown directive set_real_ip_from in /home/lnidmp/nginx/conf/

    Nginx配置跨域请求Access-Control-Allow-Origin * 详解

    Nginx配置跨域请求Access-Control-Allow-Origin * 是解决现代Web应用中常见问题的一个关键步骤。在Web开发中,由于浏览器的同源策略限制,不同源的网站之间不能直接进行AJAX请求,除非服务器允许这样的跨域行为。...

    nginx 如何实现if嵌套的方法示例

    nginx: [emerg] “if” directive is not allowed 当业务需要多个条件判断时,可以借助中间变量来实现 如:我们的网站在 pc 端有多个子域名, 而移动端只有一个域名,对应关系如下: www.test.com –> m.test.com...

    nginx 防垃圾流量的perl清洗脚本.docx

    原脚本注释掉了返回HTTP状态码`HTTP_NOT_ALLOWED`的行,但在实际应用中,这会导致返回403 Forbidden状态。不过,文档建议直接返回404 Not Found,以更隐蔽地处理垃圾流量。 3. **Nginx配置**:在Nginx的配置文件`...

    静态文件访问不到报No Access-Control-Allow-Origin处理办法

    在修改Nginx配置后,记得重启Nginx服务以使新配置生效,命令通常是`sudo service nginx restart`或者`sudo systemctl restart nginx`,具体取决于你的操作系统。 值得注意的是,虽然允许所有来源(`*`)可以方便地...

    Nginx实现跨域使用字体文件的配置详解

    在Web开发中,由于浏览器的同源策略限制,不同源的资源之间不能随意交互,这导致了当一个网站试图从另一个源加载字体文件时可能会遇到跨域问题。...Access to Font at 'http://w001.static.akhack.com/css/KohinoorBangla-Regular.ttf' from origin 'http://carey.akhack.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://carey.akhack.com' is therefore not allowed access....

    Yii 访问 Gii(脚手架)时出现 403 错误

    You are not allowed to access this page. 1、调整了文件的读写权限,通过域名访问(外网访问、本地访问),仍然403报错。 2、 然后在服务器本地访问(http://localhost/backend/web/index.php?r=gii) 仍报错403...

    已解决:No 'Access-Control-Allow-Origin'跨域问题

    <param-name>cors.allowed.methods <param-value>GET,POST,HEAD,OPTIONS,PUT <param-name>cors.allowed.headers <param-value>Access-Control-Allow-Origin,Content-Type,X-Requested-With,accept,Origin,...

    vewa_app2:VEWA 网络应用程序

    of this license document, but changing it is not allowed. 安装 用法 发展 要求 要在您的机器上运行此应用程序,您至少需要: PHP >=5.5 MySQL> = 5.5 启用了 mod rewrite 的 Apache Web Server 或 Nginx Web...

    zabbix安装文档

    如果遇到“1130-host is not allowed to connect to this MySql server”的错误,可以通过以下两种方式解决: - **方法一:** 修改MySQL的`user`表中的`host`字段,将“localhost”改为“%”。 ```bash ...

Global site tag (gtag.js) - Google Analytics