http - Nginx 中的慢速 Http Post 攻击
问题描述
为了检查我们的应用服务器中的漏洞,我们运行了 Qualys 扫描。从报告中我们发现我们的应用服务器容易受到慢速 HTTP Post 攻击。为了缓解这种攻击,我们根据 Qualys 报告(https://blog.quallys.com/securitylabs/2011/11/02/how-to-protect-against-slow-http- )在应用服务器前配置了 nginx。攻击)。根据 Qualys 的说法,如果服务器保持连接打开超过 120 秒,他们认为该服务器容易受到慢速 HTTP Post 攻击。尽管 nginx 默认超时是 60 秒,但它在我们的应用服务器中保持连接超过 2 分钟。我们还检查了 nginx 连接状态,它使连接保持在写状态超过 2 分钟。
请帮助我们配置 nginx 以防止慢速 HTTP Post 攻击。
当前的 nginx 配置
user nginx;
worker_processes auto;
worker_rlimit_nofile 102400;
events {
worker_connections 100000;
}
access_log off;
autoindex off;
limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=2r/s;
limit_conn_zone $binary_remote_addr zone=limitzone:10m;
limit_conn_status 403;
limit_req_status 403;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 20 15;
client_body_timeout 5s;
client_header_timeout 5s;
send_timeout 2;
reset_timedout_connection on;
types_hash_max_size 2048;
server_tokens off;
client_body_buffer_size 100K;
client_header_buffer_size 1k;
client_max_body_size 100k;
large_client_header_buffers 2 1k;
include /etc/nginx/mime.types;
default_type application/octet-stream;
upstream backend {
server 127.0.0.1:8080 max_conns=150;
}
server {
listen 443 ssl http2 default_server;
\# listen [::]:443 ssl http2 default_server;
server_name *******;
underscores_in_headers on;
if ($request_method !~ ^(GET|HEAD|POST|PUT|DELETE)$ ) {
return 444;
}
*** ssl configuration ***
.....
location / {
limit_conn limitzone 20;
limit_req zone=req_limit_per_ip burst=5 nodelay;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cookie_path / "/; HTTPOnly; Secure; SameSite=strict";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_pass http://backend;
}
}
解决方案
来自client_body_timeout的 NGINX 文档
超时仅设置为两次连续读取操作之间的一段时间,而不是整个请求正文的传输。如果客户端在此时间内未传输任何内容,则请求将终止并出现 408(请求超时)错误。
(强调我的)
我读到这一点,因为 Qualys 可能能够通过在 59 秒后发送块来保持连接打开,然后在 118 秒后再次发送 - 从而在保持连接打开的同时避免超时。
我不知道限制“整个请求正文的传输”的具体方法。
推荐阅读
- angular - 将方法从一个组件导出到另一个组件
- .net - 在 Windows 窗体中列出(顶级)声明的变量
- dart - Flutter - 如何制作 PageView 和 ListView?
- linux - ldd 是否报告库的所有依赖项?
- laravel - SQLSTATE [42S02]:未找到基表或视图:1146 表 'seaurchin.availableroom' 不存在 (42S02)
- python - 带有keras的卷积神经网络给出错误,UnboundLocalError:分配前引用的局部变量'a'
- android - 如何在单击按钮时获得 Recyclerview 的所有值?
- c++ - 用于 Ubuntu 的 Sublime Text 3 构建系统
- python - google colab 上的 python train.py 会在短时间内停止并仅输出一个检查点
- r - 列表:名字总是被引用