worker_processes auto; events { worker_connections 1024; multi_accept on; # Accept multiple connections at once } http { include mime.types; default_type application/octet-stream; # Optimize file transfers sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types { text/html html; text/css css; text/xml xml; image/gif gif; image/jpeg jpeg jpg; application/javascript js; application/json json; application/xml xml; application/rss+xml rss; text/plain txt; } # Improve performance and security gzip on; gzip_comp_level 6; # Compression level (1-9) gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/rss+xml; gzip_proxied any; gzip_vary on; gzip_disable "msie6"; # Disable gzip for older browsers server { listen 7860; # Use standard port 80 for HTTP server_name chandima-prabath-nectjs-serve.hf.space; # Replace with your actual domain location / { # Proxy requests to the Next.js application running on port 3000 proxy_pass http://localhost:3000; 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; # Add caching headers for static assets expires 1d; add_header Cache-Control "public"; } # Handle 404 errors error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; internal; } # Handle 500 errors error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; internal; } # Deny access to sensitive files location ~ /\.(ht|git) { deny all; } } }