# Redirect all HTTP traffic to HTTPS
server {
    listen 80;
    server_name client.spotify.vish.gg;

    return 301 https://$host$request_uri;
}

# HTTPS configuration for the subdomain
server {
    listen 443 ssl;
    server_name client.spotify.vish.gg;

    # SSL Certificates (managed by Certbot)
    ssl_certificate /etc/letsencrypt/live/client.spotify.vish.gg/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/client.spotify.vish.gg/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    # Proxy to Docker container
    location / {
        proxy_pass http://127.0.0.1:4000; # Maps to your Docker container
        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;
    }
}
