书接上回,刚迁到服务器,东西还没完全配完,就从日志里看到不少蟑螂了!虽然是静态博客,但是看到这些蟑螂爬来爬去的还是很恶心,果断禁掉。
- 拦截各种 php 遍历
- 拦截各种不存在的 rss 遍历(只对真实路径放行)
- 拦截各种隐藏路径遍历
map $http_user_agent $bad_bot { default 0; "~*(sqlmap|curl|python|masscan|dirbuster|\.py|\\x[0-9a-fA-F]{2})" 1; }
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
server { listen 80; server_name xaoxuu.com;
location = / { return 301 https://$host$request_uri; }
location ~* \.\w+$ { return 301 https://$host$request_uri; }
return 444; }
server { listen 443 ssl http2; server_name xaoxuu.com;
index index.html;
access_log /www/sites/xaoxuu.com/log/access.log main; error_log /www/sites/xaoxuu.com/log/error.log;
if ($bad_bot) { return 444; }
location / { limit_req zone=one burst=20 nodelay; try_files $uri $uri/ =404; }
location ~* \.php$|\.asp$|\.aspx$|\.jsp$|\.cgi$ { return 444; }
location ~* ^/(rss\.xml|rss2\.xml|index\.xml|feed(/.*)?)$ { return 444; }
location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md) { return 404; }
location ~ /\.(?!well-known).* { deny all; }
location ^~ /.well-known { allow all; root /usr/share/nginx/html; }
location ~* ^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$ { return 403; }
root /www/sites/xaoxuu.com/index;
error_page 404 /404.html;
location = /404.html { root /www/sites/xaoxuu.com/index; }
ssl_certificate /path/to/fullchain.pem; ssl_certificate_key /path/to/privkey.pem; ssl_protocols TLSv1.3 TLSv1.2; ssl_ciphers ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:!aNULL:!eNULL:!EXPORT:!DSS:!DES:!RC4:!3DES:!MD5:!PSK:!KRB5:!SRP:!CAMELLIA:!SEED; ssl_prefer_server_ciphers off; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
include /www/sites/xaoxuu.com/proxy/*.conf; }
|