【发布时间】:2020-11-16 14:54:09
【问题描述】:
我目前正在尝试使用此脚本设置 WAF/DDOS 保护: https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS/blob/master/lua/anti_ddos_challenge.lua
如果其中一个 WAF 规则被命中,除了 openresty/nginx 返回默认的 500 错误页面而不是下面显示的自定义 error_page 之外,一切都运行良好。请参阅上面脚本中的“WAF_URI_Request_table”。
每次请求被这些 WAF 规则阻止时,我还会在我的日志中看到以下条目:
2020/07/27 09:20:29 [error] 150#150: *16 rewrite or internal redirection cycle while internally redirecting to "/403.html", client: 172.21.0.5, server: localhost, request: "GET /test.php HTTP/1.1", host: "localhost"
我的 nginx 配置看起来像这样(缩短):
...
http {
upstream backend {
server 127.0.0.1:8000 max_fails=3 fail_timeout=60s;
}
...
server {
listen 80;
access_by_lua_file ddos_challenge.lua;
aio threads=default;
...
location @proxy_to_app {
proxy_pass http://backend;
aio threads;
proxy_read_timeout 100s;
proxy_connect_timeout 100s;
proxy_http_version 1.1;
proxy_redirect off;
proxy_buffers 16 4k;
proxy_buffer_size 2k;
proxy_intercept_errors on;
proxy_set_header Host $host;
uwsgi_intercept_errors on;
gzip on;
gzip_min_length 1024;
gzip_comp_level 3;
gzip_vary on;
gzip_disable msie6;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
}
location / {
try_files $uri @proxy_to_app;
}
...
error_page 412 414 416 444 495 496 497 500 501 502 504 507 /custom_error.html;
location = /custom_error.html {
root /app/templates/;
internal;
}
【问题讨论】:
-
您是否尝试将
/custom_error.html位置移动到/上方?