Chandima Prabhath commited on
Commit ·
29f13f9
1
Parent(s): cc2caf9
Refactor Nginx configuration for improved performance and security
Browse files12345678910111213141516171819202122232425262728293031worker_processes 1;events { worker_connections 1024; }http {include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server {listen 7860;server_name localhost;root /usr/share/nginx/html;index index.html;# Serve files, fallback to index.html for client‑side routinglocation / {try_files $uri $uri/ /index.html;}# Optional: caching static assetslocation ~* \.(js|css|png|jpg|jpeg|gif|svg|ico)$ {expires 30d;add_header Cache-Control "public";}}}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495#------------------------------------------------------------------# Global Settings#------------------------------------------------------------------worker_processes auto;worker_rlimit_nofile 100000;events {worker_connections 4096;multi_accept on;}http {# Basic includesinclude /opt/bitnami/nginx/conf/mime.types;default_type application/octet-stream;# I/O optimizationssendfile on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 65;# Caching open file descriptorsopen_file_cache max=1000 inactive=20s;open_file_cache_valid 30s;open_file_cache_min_uses 2;open_file_cache_errors off;# Hide Nginx versionserver_tokens off;#------------------------------------------------------------------# Gzip Compression#------------------------------------------------------------------gzip on;gzip_disable "msie6";gzip_vary on;gzip_proxied any;gzip_comp_level 5;gzip_buffers 16 8k;gzip_http_version 1.1;gzip_typestext/plaintext/cssapplication/jsonapplication/javascripttext/xmlapplication/xmlapplication/xml+rsstext/javascript;# (If your image supports Brotli, you could also enable it here)#------------------------------------------------------------------# Server Block#------------------------------------------------------------------server {listen 7860;listen [::]:7860;server_name localhost;root /usr/share/nginx/html;index index.html;# Security headersadd_header X-Frame-Options "SAMEORIGIN";add_header X-Content-Type-Options "nosniff";add_header X-XSS-Protection "1; mode=block";add_header Referrer-Policy "no-referrer-when-downgrade";# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;# SPA routing: try file, dir, then fallback to index.htmllocation / {try_files $uri $uri/ /index.html;}# Static assets: long cache + no logslocation ~* \.(?:css|js|json|txt|xml|woff2?|ttf|eot)$ {access_log off;log_not_found off;expires 30d;add_header Cache-Control "public, no-transform";}location ~* \.(?:png|jpe?g|gif|ico|svg)$ {access_log off;log_not_found off;expires 30d;add_header Cache-Control "public, no-transform";}# Fallback 404s to index for client‑side routingerror_page 404 /index.html;}}
nginx.conf+86-22