# Nginx Config für linkedin.onyva.dev
# Füge das zur bestehenden Nginx-Config hinzu (z.B. in Coolify oder /etc/nginx/sites-available/)

server {
    listen 80;
    server_name linkedin.onyva.dev;

    # Let's Encrypt ACME Challenge (für SSL)
    location /.well-known/acme-challenge/ {
        root /var/www/certbot;
    }

    # Redirect zu HTTPS
    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl http2;
    server_name linkedin.onyva.dev;

    # SSL Zertifikate (passe den Pfad an)
    ssl_certificate /etc/letsencrypt/live/linkedin.onyva.dev/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/linkedin.onyva.dev/privkey.pem;

    # SSL Settings
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    # Security Headers
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;

    # Logs
    access_log /var/log/nginx/linkedin-access.log;
    error_log /var/log/nginx/linkedin-error.log;

    # Client Max Body Size (für Bild-Uploads)
    client_max_body_size 10M;

    # Proxy zu Docker Container
    location / {
        proxy_pass http://127.0.0.1:8001;
        proxy_http_version 1.1;

        # Proxy Headers
        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;

        # Timeouts
        proxy_connect_timeout 60s;
        proxy_send_timeout 60s;
        proxy_read_timeout 60s;
    }
}
