# Design System Server (DSS) - Nginx Configuration
# Domain: dss.overbits.luz.uy
# Port: 3456
#
# Installation:
#   sudo cp /home/overbits/apps/design-system-swarm/infra/dss.overbits.luz.uy.conf /etc/nginx/sites-available/
#   sudo ln -sf /etc/nginx/sites-available/dss.overbits.luz.uy.conf /etc/nginx/sites-enabled/
#   sudo certbot --nginx -d dss.overbits.luz.uy
#   sudo nginx -t && sudo systemctl reload nginx
#
# Note: Remove old ds.overbits.luz.uy.conf after migration

server {
    server_name dss.overbits.luz.uy;

    access_log /var/log/nginx/dss_overbits_access.log;
    error_log /var/log/nginx/dss_overbits_error.log;

    auth_basic "DSS Restricted";
    auth_basic_user_file /etc/nginx/.htpasswd_ds_overbits;

    # All requests go to the Fastify server on port 3456
    location / {
        proxy_pass http://127.0.0.1:3456;
        proxy_http_version 1.1;
        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_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        # Timeouts for long-running operations
        proxy_connect_timeout 60s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
    }

    # Certbot will add SSL config below
    listen 80;
}
