解决“HTTP/1.1 405 Method not allowed”问题,让静态文件响应POST请求
Nginx等绝大多数web服务器,都不允许静态文件响应POST请求,否则会返回“HTTP/1.1 405 Method not allowed”错误。
参考:
1 2 3 4 5
| error_page 405 =200 @405; location @405 { proxy_method GET; proxy_pass http://$host; }
|
实际配置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| server { listen 80; server_name xxx.com.cn; location /html { proxy_pass http://127.0.0.1:6702/; } }
server { listen 6702; server_name 127.0.0.1; error_page 405 =200 @405; location @405 { proxy_method GET; proxy_pass http://127.0.0.1:6702; } location / { root /data/h5/home; } }
server { listen 6703; server_name 127.0.0.1; location / { root /data/h5/home; } }
|