user nginx; worker_processes auto; pid /var/run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Logging Settings access_log /dev/stdout; error_log /dev/stderr warn; server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; location /app-data/ { include /etc/nginx/nginx-auth.conf; # Apply Basic Auth to API proxy_pass http://127.0.0.1:3000/; # Node API listens on port 3000 locally proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; 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; } # Enable gzip compression gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; # Deny direct access to any files that might be mapped under a /data/ URI path location /data/ { deny all; return 404; # Or 403 Forbidden } location / { include /etc/nginx/nginx-auth.conf; # Apply Basic Auth to the whole site try_files $uri $uri/ /index.html; } # Enable browser caching for static assets location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { include /etc/nginx/nginx-auth.conf; # Apply Basic Auth to static assets too expires 30d; add_header Cache-Control "public, no-transform"; } # Error pages error_page 404 /index.html; # Consider a specific 404.html if you have one error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; # Ensure 50x.html is in the root } } # End of server block } # End of http block