# /etc/nginx/sites-available/nexus.noveria.net
# Symlink: ln -s /etc/nginx/sites-available/nexus.noveria.net /etc/nginx/sites-enabled/

server {
    listen 80;
    server_name nexus.noveria.net;

    # Let's Encrypt challenge
    location /.well-known/acme-challenge/ {
        root /var/www/html;
    }

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

server {
    listen 443 ssl http2;
    server_name nexus.noveria.net;

    # SSL wird per certbot automatisch befüllt
    ssl_certificate     /etc/letsencrypt/live/nexus.noveria.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nexus.noveria.net/privkey.pem;

    # Security-Header
    add_header Strict-Transport-Security "max-age=63072000" always;
    add_header X-Content-Type-Options nosniff;
    add_header X-Frame-Options DENY;

    client_max_body_size 16m;

    location / {
        proxy_pass http://127.0.0.1:18880;
        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;
    }

    # API-Direktzugriff falls nötig
    location /api/ {
        proxy_pass http://127.0.0.1:18880;
        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;
    }
}
