|
|
|
worker_processes auto; |
|
|
|
|
|
worker_rlimit_nofile 65535; |
|
|
|
events { |
|
|
|
worker_connections 65535; |
|
|
|
|
|
multi_accept on; |
|
|
|
|
|
use epoll; |
|
} |
|
|
|
http { |
|
|
|
|
|
|
|
keepalive_timeout 65; |
|
keepalive_requests 100; |
|
|
|
|
|
gzip on; |
|
gzip_vary on; |
|
gzip_proxied any; |
|
gzip_comp_level 6; |
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; |
|
|
|
|
|
access_log /tmp/nginx_access.log; |
|
error_log /tmp/nginx_error.log; |
|
|
|
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s; |
|
limit_conn_zone $binary_remote_addr zone=addr:10m; |
|
|
|
include /etc/nginx/mime.types; |
|
|
|
|
|
upstream backend { |
|
least_conn; |
|
server 127.0.0.1:3000 max_fails=3 fail_timeout=30s; |
|
keepalive 32; |
|
} |
|
|
|
server { |
|
listen 7860 reuseport; |
|
listen [::]:7860 reuseport; |
|
server_name localhost; |
|
|
|
|
|
|
|
location /hf/ { |
|
rewrite ^/hf/(.*)$ /$1 break; |
|
limit_req zone=one burst=15 nodelay; |
|
limit_conn addr 5; |
|
proxy_pass http://backend; |
|
proxy_set_header Upgrade $http_upgrade; |
|
proxy_set_header Connection "upgrade"; |
|
proxy_set_header Host $host; |
|
|
|
|
|
proxy_set_header X-Forwarded-For ""; |
|
proxy_set_header X-Real-IP ""; |
|
proxy_set_header X-Direct-Url ""; |
|
proxy_set_header X-Forwarded-Port ""; |
|
proxy_set_header X-Ip-Token ""; |
|
proxy_set_header X-Request-Id ""; |
|
proxy_set_header X-Amzn-Trace-Id ""; |
|
proxy_set_header X-Forwarded-Proto ""; |
|
|
|
|
|
proxy_buffering off; |
|
proxy_cache off; |
|
proxy_connect_timeout 60s; |
|
proxy_send_timeout 60s; |
|
proxy_read_timeout 60s; |
|
error_page 503 =429 /429.html; |
|
} |
|
|
|
location / { |
|
limit_req zone=one burst=20 nodelay; |
|
limit_conn addr 10; |
|
proxy_pass http://backend; |
|
proxy_set_header Upgrade $http_upgrade; |
|
proxy_set_header Connection "upgrade"; |
|
proxy_set_header Host $host; |
|
|
|
|
|
proxy_set_header X-Forwarded-For ""; |
|
proxy_set_header X-Real-IP ""; |
|
proxy_set_header X-Direct-Url ""; |
|
proxy_set_header X-Forwarded-Port ""; |
|
proxy_set_header X-Ip-Token ""; |
|
proxy_set_header X-Request-Id ""; |
|
proxy_set_header X-Amzn-Trace-Id ""; |
|
proxy_set_header X-Forwarded-Proto ""; |
|
|
|
|
|
proxy_buffering off; |
|
proxy_cache off; |
|
proxy_connect_timeout 60s; |
|
proxy_send_timeout 60s; |
|
proxy_read_timeout 60s; |
|
|
|
error_page 503 =429 /429.html; |
|
} |
|
|
|
location = /429.html { |
|
return 429 'Too Many Requests'; |
|
} |
|
} |
|
} |