个人博客地址:解决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;
}
}