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

}
相关推荐
裕晟资质规划7 小时前
三类资质变更报告时限差在哪?军工 15 日、集成印制 10 日
大数据·服务器·网络
轻舟技术A7 小时前
Provider 不属于 Agent 核心:rpi 的分层理由与收益
服务器·网络
Escalating_xu7 小时前
【Linux 网络编程】TCP Socket 编程(上):从 listen、accept 到完整回显通信
linux·网络·tcp/ip
NetX行者7 小时前
Python 工程化入门:从脚本到规范的 Python 项目结构
网络·python
Yang96117 小时前
从相位噪声到实时带宽:HD-063B支撑的频谱实验项目
网络
happyprince7 小时前
01-整体观-DeepSeek-V4.1-Flash全貌解读
网络
是真的小外套8 小时前
2023年软考中级信息安全工程师|选择题考点+5道案例分析真题解析(含答案)
java·服务器·网络
一条泥憨鱼9 小时前
【计算机网络】| 从 MAC 到 NAT 的跨网段通信全链路
服务器·网络·学习·计算机网络·macos
Moyu_Friday9 小时前
网络安全基础-计算机网络应用与协议
网络协议·计算机网络