server {
    listen 80;
    server_name localhost;

    client_max_body_size 20M;

    # ──────────────────────────────────────────────
    # Portal-Selektor (Webroot: /)
    # ──────────────────────────────────────────────
    root /usr/share/nginx/html/portal;

    # Never cache sw.js and manifest.json (served from portal root)
    location = /sw.js {
        add_header Cache-Control "no-cache, no-store, must-revalidate";
        expires 0;
    }

    location = /manifest.json {
        add_header Cache-Control "no-cache, no-store, must-revalidate";
        expires 0;
    }

    # ──────────────────────────────────────────────
    # Nachsuche  (/nachsuche/)
    # ──────────────────────────────────────────────
    location /nachsuche/api/ {
        proxy_pass         http://host.docker.internal:5000/api/;
        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 $http_x_forwarded_proto;
        proxy_connect_timeout 60s;
        proxy_send_timeout    60s;
        proxy_read_timeout    60s;
    }

    location /nachsuche/ {
        proxy_pass         http://host.docker.internal:8080/;
        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 $http_x_forwarded_proto;
        proxy_connect_timeout 60s;
        proxy_send_timeout    60s;
        proxy_read_timeout    60s;
    }

    # ──────────────────────────────────────────────
    # Drohnenführer  (/drohnenfuehrer/)
    # ──────────────────────────────────────────────
    location /drohnenfuehrer/api/ {
        proxy_pass         http://host.docker.internal:5001/api/;
        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 $http_x_forwarded_proto;
        proxy_connect_timeout 60s;
        proxy_send_timeout    60s;
        proxy_read_timeout    60s;
    }

    location /drohnenfuehrer/ {
        proxy_pass         http://host.docker.internal:8081/;
        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 $http_x_forwarded_proto;
        proxy_connect_timeout 60s;
        proxy_send_timeout    60s;
        proxy_read_timeout    60s;
    }

    # ──────────────────────────────────────────────
    # Stöberhunde  (/stoeberhunde/)
    # ──────────────────────────────────────────────
    location /stoeberhunde/api/ {
        proxy_pass         http://host.docker.internal:5002/api/;
        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 $http_x_forwarded_proto;
        proxy_connect_timeout 60s;
        proxy_send_timeout    60s;
        proxy_read_timeout    60s;
    }

    location /stoeberhunde/ {
        proxy_pass         http://host.docker.internal:8082/;
        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 $http_x_forwarded_proto;
        proxy_connect_timeout 60s;
        proxy_send_timeout    60s;
        proxy_read_timeout    60s;
    }

    # ──────────────────────────────────────────────
    # Portal-Selektor catch-all  (index.html)
    # ──────────────────────────────────────────────
    location / {
        try_files $uri $uri/ /index.html;
        add_header Cache-Control "no-cache, no-store, must-revalidate";
        expires 0;
    }
}

