# Don't set user - let Docker/container do that # user nginx; server { listen 3000; server_name _; root /usr/share/nginx/html; index index.html index.htm; # Gzip compression gzip on; gzip_types text/plain text/css text/javascript application/javascript application/json; gzip_min_length 1000; # Cache control location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable"; } # HTML - don't cache location ~* \.html$ { expires -1; add_header Cache-Control "no-cache, no-store, must-revalidate"; } # API proxy location /api/ { proxy_pass https://dev-api.rideaware.org; proxy_http_version 1.1; proxy_set_header Host dev-api.rideaware.org; 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-Host $host; proxy_cache_bypass $http_upgrade; # CORS headers add_header 'Access-Control-Allow-Origin' '*' always; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS' always; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always; if ($request_method = 'OPTIONS') { add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization'; add_header 'Content-Type' 'text/plain charset=UTF-8'; add_header 'Content-Length' 0; return 204; } } # SPA - route all requests to index.html location / { try_files $uri $uri/ /index.html; expires -1; add_header Cache-Control "no-cache, no-store, must-revalidate"; } # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; # Error pages error_page 404 /index.html; error_page 500 502 503 504 /index.html; }