| user nginx; |
| worker_processes auto; |
| error_log /var/log/nginx/error.log warn; |
| pid /var/run/nginx.pid; |
|
|
| events { |
| worker_connections 1024; |
| } |
|
|
| http { |
| include /etc/nginx/mime.types; |
| default_type application/octet-stream; |
| log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
| '$status $body_bytes_sent "$http_referer" ' |
| '"$http_user_agent" "$http_x_forwarded_for"'; |
| access_log /var/log/nginx/access.log main; |
| sendfile on; |
| tcp_nopush on; |
| tcp_nodelay on; |
| keepalive_timeout 65; |
| types_hash_max_size 2048; |
|
|
| # SSL configuration |
| ssl_protocols TLSv1.2 TLSv1.3; |
| ssl_prefer_server_ciphers on; |
| ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; |
| ssl_session_timeout 1d; |
| ssl_session_cache shared:SSL:50m; |
| ssl_session_tickets off; |
| ssl_stapling on; |
| ssl_stapling_verify on; |
| resolver 8.8.8.8 8.8.4.4 valid=300s; |
| resolver_timeout 5s; |
|
|
| # Define upstream servers for load balancing |
| upstream app_servers { |
| least_conn; # Use least connections algorithm for load balancing |
| |
| # Add all 10 servers |
| server localhost:7850; |
| server localhost:7851; |
| server localhost:7852; |
| server localhost:7853; |
| server localhost:7854; |
| server localhost:7855; |
| server localhost:7856; |
| server localhost:7857; |
| server localhost:7858; |
| server localhost:7859; |
| } |
|
|
| # Redirect HTTP to HTTPS |
| server { |
| listen 80; |
| server_name 158.130.50.41; # Change this to your domain name |
| return 301 https://$server_name$request_uri; |
| } |
| |
| |
| server { |
| listen 443 ssl http2; |
| server_name 158.130.50.41; |
| |
| |
| ssl_certificate /etc/nginx/ssl/cert.pem; |
| ssl_certificate_key /etc/nginx/ssl/key.pem; |
| |
| |
| location / { |
| proxy_pass http://app_servers; |
| proxy_http_version 1.1; |
| proxy_set_header Upgrade $http_upgrade; |
| proxy_set_header Connection "upgrade"; |
| proxy_set_header Host $host; |
| proxy_set_header X-Real-IP $remote_addr; |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| proxy_set_header X-Forwarded-Proto $scheme; |
| proxy_set_header X-Forwarded-Ssl on; |
| |
| |
| proxy_read_timeout 300s; |
| proxy_send_timeout 300s; |
| proxy_connect_timeout 75s; |
| |
| |
| proxy_buffering off; |
| proxy_buffer_size 128k; |
| proxy_buffers 4 256k; |
| proxy_busy_buffers_size 256k; |
| } |
| |
| |
| location /health { |
| access_log off; |
| return 200 'healthy\n'; |
| } |
| |
| |
| add_header Strict-Transport-Security "max-age=63072000" always; |
| add_header X-Frame-Options DENY; |
| add_header X-Content-Type-Options nosniff; |
| add_header X-XSS-Protection "1; mode=block"; |
| } |
| } |