File size: 2,073 Bytes
6ba7c23 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
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;
}
}
}
|