Nginx - 405 not allowed ft. Cloudflare
Nginx 405 not allowed 解決方式
Updated
•1 min read
Nginx 405 not allowed 解決方式
修正 nginx 出現 405 方法拒絕

前言
本篇的錯誤發生於 cloudflare 設置 DDoS Protection 機制後發生
在 cloudflare 經過此機制後會向 server 發送 POST 事件
由於 nginx 預設禁止靜態資源配置 POST 請求
因此發生禁止的 Response
設置
將 nginx 設置關於 error_page 的捕捉
[ default.conf ]
server {
listen 80;
listen [::]:80;
return 301 https://$host$request_uri;
}
server {
# ...
error_page 405 =200 https://$host$request_uri;
}
參考
- https://stackoverflow.com/questions/24415376/post-request-not-allowed-405-not-allowed-nginx-even-with-headers-included
- https://www.izhangheng.com/nginx-405-not-allowed
- https://cloud.tencent.com/developer/article/1680056
- https://github.com/denysvitali/nginx-error-pages
有勘誤之處,不吝指教。ob'_'ov
9 views



