# Nginx reverse proxy config for DocFast
# Place in /etc/nginx/sites-available/docfast.conf and symlink to sites-enabled
# Requires: certbot for SSL (or existing wildcard cert)

server {
    listen 80;
    server_name api.docfast.dev;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    server_name api.docfast.dev;

    # SSL certs (adjust paths)
    ssl_certificate /etc/letsencrypt/live/api.docfast.dev/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/api.docfast.dev/privkey.pem;

    # Security headers
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";

    # Max body size (HTML/Markdown input)
    client_max_body_size 2m;

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

        # PDF responses can be large
        proxy_read_timeout 30s;
        proxy_buffering off;
    }
}
