mailman-nginx.conf (3323B)
1 worker_processes auto; 2 pid /tmp/nginx.pid; 3 error_log /dev/stderr warn; 4 5 events { 6 worker_connections 1024; # Reduced for container environment 7 use epoll; # Efficient event method for Linux 8 multi_accept on; # Accept multiple connections at once 9 } 10 11 http { 12 # Temp paths for unprivileged mode 13 client_body_temp_path /tmp/nginx/client_body; 14 fastcgi_temp_path /tmp/nginx/fastcgi; 15 uwsgi_temp_path /tmp/nginx/uwsgi; 16 scgi_temp_path /tmp/nginx/scgi; 17 proxy_temp_path /tmp/nginx/proxy; 18 19 # Basic optimizations 20 sendfile on; 21 tcp_nopush on; 22 tcp_nodelay on; 23 keepalive_timeout 65; 24 keepalive_requests 100; 25 26 # Buffer optimizations 27 client_body_buffer_size 128k; 28 client_max_body_size 20m; # For email attachments 29 client_header_buffer_size 1k; 30 large_client_header_buffers 4 4k; 31 32 # Gzip compression 33 gzip on; 34 gzip_vary on; 35 gzip_min_length 1000; 36 gzip_comp_level 6; 37 gzip_types 38 text/plain 39 text/css 40 text/xml 41 text/javascript 42 application/json 43 application/javascript 44 application/xml+rss 45 application/atom+xml 46 image/svg+xml; 47 48 # Logging (structured for container environments) 49 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 50 '$status $body_bytes_sent "$http_referer" ' 51 '"$http_user_agent" "$http_x_forwarded_for" ' 52 'rt=$request_time uct="$upstream_connect_time" ' 53 'uht="$upstream_header_time" urt="$upstream_response_time"'; 54 access_log /dev/stdout main; 55 56 server_names_hash_bucket_size 64; 57 include /etc/nginx/mime.types; 58 default_type application/octet-stream; 59 server { 60 listen 9090; 61 server_name _; 62 63 # Security headers (behind reverse proxy) 64 add_header X-Content-Type-Options nosniff; 65 add_header X-Frame-Options DENY; 66 add_header X-XSS-Protection "1; mode=block"; 67 68 location /static { 69 alias /opt/mailman-web-data/static; 70 autoindex off; 71 72 # Static file caching 73 expires 1M; 74 add_header Cache-Control "public, immutable"; 75 add_header Vary Accept-Encoding; 76 77 # Efficient static file serving 78 location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { 79 expires 1y; 80 add_header Cache-Control "public, immutable"; 81 } 82 } 83 84 location / { 85 # uWSGI connection with optimized settings 86 uwsgi_pass 127.0.0.1:8080; 87 #proxy_pass http://127.0.0.1:8000; 88 include uwsgi_params; 89 90 # Timeout settings 91 uwsgi_read_timeout 300; 92 uwsgi_connect_timeout 60; 93 94 # Buffer settings for better performance 95 uwsgi_buffer_size 64k; 96 uwsgi_buffers 4 64k; 97 uwsgi_busy_buffers_size 128k; 98 99 # Pass real client info (since behind reverse proxy) 100 uwsgi_param HTTP_X_FORWARDED_PROTO $scheme; 101 uwsgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for; 102 uwsgi_param HTTP_X_REAL_IP $remote_addr; 103 } 104 } 105 } 106