# Nginx Configuration for Custom 404 Page # Add this to your nginx server block configuration server { listen 80; server_name your-domain.com; root /path/to/your/website; index index.html; # Custom 404 error page error_page 404 /404.html; # Handle 404 errors for missing files location = /404.html { internal; root /path/to/your/website; } # Try files, fallback to 404 location / { try_files $uri $uri/ =404; } # Security headers add_header X-Content-Type-Options nosniff; add_header X-Frame-Options DENY; add_header X-XSS-Protection "1; mode=block"; # Cache static assets location ~* \.(ico|css|js|gif|jpe?g|png)$ { expires 1y; add_header Cache-Control "public, immutable"; } } # Instructions: # 1. Replace 'your-domain.com' with your actual domain # 2. Replace '/path/to/your/website' with your actual website path # 3. Add this configuration to your nginx sites-available file # 4. Test configuration: sudo nginx -t # 5. Reload nginx: sudo systemctl reload nginx