解决HTTP POST请求Nginx静态内容405错误

个人博客地址:解决HTTP POST请求Nginx静态内容405错误 | 一张假钞的真实世界

Nginx是不支持POST请求静态内容的,通过POST请求时出现以下错误:

bash 复制代码
# curl -d "a=b" "http://192.16.36.15:11013/upgrade"
<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配置中添加以下配置:

bash 复制代码
error_page 405 =200 $uri;

完整配置示例如下:

bash 复制代码
server {
    listen       80;
    server_name  localhost;

    location /upgrade {
        empty_gif;
        access_log /data/nginx/upgrade.log;
    }

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    error_page 405 =200 $uri;
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}
相关推荐
bufengwangluo15 小时前
动态代理IP是什么?从IP池到自动切换的工作机制解读
服务器·网络·ip
西泽XIZ917 小时前
微信小程序网络与数据库交互实践:从后端环境搭建到数据渲染
网络·数据库·微信小程序·小程序
如夏倾城1 天前
大模型(Large Model)解析:从数据类型、模型架构到任务选型
服务器·网络·数据库·语言模型·架构·audiolm
郝学胜-神的一滴1 天前
Effective STL 条款12:对容器线程安全性的现实期望
c语言·开发语言·c++·qt·网络协议·rpc·numpy
Risehuxyc1 天前
MTU 和 MSS 详解
网络·智能路由器
ikgy1 天前
JAVA EE:7.网络初识
网络
AlanAshley1 天前
移动端省流方案:压缩+缓存
网络·缓存
EmbeddedChen1 天前
Linux 怎么查看 IP 地址和网络状态?常用网络命令入门
linux·网络·ip·route·ping
FakeOccupational1 天前
fpga系列 HDL : 选择RAM IP(Two Port IP核) 乒乓缓冲(Ping-Pong Buffer)工作流程
网络协议·tcp/ip·fpga开发
爱和冰阔落1 天前
【Linux网络】GET 和 POST 真的只是参数位置不同吗?从 HTTP 请求方法、抓包分析到长连接与路由实战
linux·c++·http·网络编程·get与post