|
| 1 | +# AngelaMos | 2025 |
| 2 | +# nginx.prod.conf |
| 3 | +# Production nginx configuration (no dev frontend upstream) |
| 4 | + |
| 5 | +worker_processes auto; |
| 6 | +worker_rlimit_nofile 65535; |
| 7 | + |
| 8 | +error_log /var/log/nginx/error.log warn; |
| 9 | +pid /var/run/nginx.pid; |
| 10 | + |
| 11 | +events { |
| 12 | + worker_connections 4096; |
| 13 | + multi_accept on; |
| 14 | + use epoll; |
| 15 | +} |
| 16 | + |
| 17 | +http { |
| 18 | + include /etc/nginx/mime.types; |
| 19 | + default_type application/octet-stream; |
| 20 | + |
| 21 | + # WebSocket upgrade handling |
| 22 | + map $http_upgrade $connection_upgrade { |
| 23 | + default upgrade; |
| 24 | + '' close; |
| 25 | + } |
| 26 | + |
| 27 | + upstream backend { |
| 28 | + server backend:8000 max_fails=3 fail_timeout=30s; |
| 29 | + keepalive 32; |
| 30 | + keepalive_requests 1000; |
| 31 | + keepalive_timeout 60s; |
| 32 | + } |
| 33 | + |
| 34 | + limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/s; |
| 35 | + limit_req_zone $binary_remote_addr zone=auth_limit:10m rate=1r/s; |
| 36 | + limit_conn_zone $binary_remote_addr zone=conn_limit:10m; |
| 37 | + limit_req_status 429; |
| 38 | + |
| 39 | + log_format main_timed '$remote_addr - $remote_user [$time_local] ' |
| 40 | + '"$request" $status $body_bytes_sent ' |
| 41 | + '"$http_referer" "$http_user_agent" ' |
| 42 | + 'rt=$request_time uct="$upstream_connect_time" ' |
| 43 | + 'uht="$upstream_header_time" urt="$upstream_response_time"'; |
| 44 | + |
| 45 | + sendfile on; |
| 46 | + tcp_nopush on; |
| 47 | + tcp_nodelay on; |
| 48 | + keepalive_timeout 65; |
| 49 | + types_hash_max_size 2048; |
| 50 | + server_tokens off; |
| 51 | + |
| 52 | + # Buffer sizes |
| 53 | + client_body_buffer_size 128k; |
| 54 | + client_header_buffer_size 16k; |
| 55 | + client_max_body_size 10m; |
| 56 | + large_client_header_buffers 4 16k; |
| 57 | + |
| 58 | + client_body_timeout 12s; |
| 59 | + client_header_timeout 12s; |
| 60 | + send_timeout 10s; |
| 61 | + |
| 62 | + gzip on; |
| 63 | + gzip_vary on; |
| 64 | + gzip_proxied any; |
| 65 | + gzip_comp_level 6; |
| 66 | + gzip_min_length 256; |
| 67 | + gzip_types |
| 68 | + text/plain |
| 69 | + text/css |
| 70 | + text/xml |
| 71 | + text/javascript |
| 72 | + application/json |
| 73 | + application/javascript |
| 74 | + application/xml+rss |
| 75 | + application/atom+xml |
| 76 | + image/svg+xml; |
| 77 | + gzip_disable "msie6"; |
| 78 | + |
| 79 | + # Include server blocks |
| 80 | + include /etc/nginx/conf.d/*.conf; |
| 81 | +} |
0 commit comments