# /etc/nginx/sites-available/naukrialert
#
# Install:
#   sudo cp nginx.conf /etc/nginx/sites-available/naukrialert
#   sudo ln -s /etc/nginx/sites-available/naukrialert /etc/nginx/sites-enabled/naukrialert
#   sudo rm -f /etc/nginx/sites-enabled/default
#   sudo nginx -t && sudo systemctl reload nginx
#
# Then add HTTPS (certbot edits this file for you and adds the 443 block + redirect):
#   sudo certbot --nginx -d naukrialert247.in -d www.naukrialert247.in
#
# NOTE: the Node app (PM2) must be running on port 5000 first:  pm2 status

server {
    listen 80;
    listen [::]:80;
    server_name naukrialert247.in www.naukrialert247.in;

    # Compression
    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 5;
    gzip_min_length 1024;
    gzip_types text/plain text/css text/javascript application/javascript application/json application/xml text/xml image/svg+xml;

    # Everything (site + API) is served by the Node app. Caching headers are set by the app itself:
    #   HTML -> always revalidate, CSS/JS -> 1 hour, images/fonts -> 7 days
    location / {
        proxy_pass http://127.0.0.1:5000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        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_cache_bypass $http_upgrade;
        proxy_read_timeout 300;
    }
}
