upstream puma__production {
server unix:home/deploy/demo/shared/tmp/sockets/puma.sock fail_timeout=0;
}
limit_conn_status 404;
#通过“漏桶”算法限制每个 IP 发起的请求频率。
limit_req_zone $binary_remote_addr zone=sym:10m rate=30r/m;
#限制每个 IP 发起的连接数。
limit_conn_zone $binary_remote_addr zone=conn_sym:10m;
limit_conn_zone $server_name zone=perserver:10m;
server{
listen 80;
server_name csdn.com www.csdn.com;
root /home/deploy/demo/current/public;
try_files $uri/index.html $uri @puma__production;
client_max_body_size 4G;
keepalive_timeout 10;
error_page 500 502 504 /500.html;
error_page 503 @503;
location @puma__production {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Forwarded-Proto http;
proxy_pass http://puma__production;
# limit_req zone=one;
access_log /home/deploy/demo/shared/log/nginx.access.log;
error_log /home/deploy/demo/shared/log/nginx.error.log;
}
location ~ ^assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
location = /50x.html {
root html;
}
location = /404.html {
root html;
}
location @503 {
error_page 405 = /system/maintenance.html;
if (-f $document_root/system/maintenance.html) {
rewrite ^(.*)$ /system/maintenance.html break;
}
rewrite ^(.*)$ /503.html break;
}
if ($request_method !~ ^(GET|HEAD|PUT|PATCH|POST|DELETE|OPTIONS)$ ){
return 405;
}
if (-f $document_root/system/maintenance.html) {
return 503;
}
} 148,1 Bot