# Host-based routing: mifi.dev / www.mifi.dev → dev root, mifi.bio / www.mifi.bio → bio root
# Security headers are handled upstream by Traefik

server {
    listen 80 default_server;
    server_name mifi.dev www.mifi.dev;
    root /usr/share/nginx/html/dev;
    index index.html;

    # Map canonical .well-known paths to variant-specific files (alias cannot use variables)
    location = /.well-known/security.txt {
        alias /usr/share/nginx/html/dev/.well-known/dev.security.txt;
        add_header Cache-Control "public, max-age=86400";
    }
    location = /.well-known/appspecific/com.chrome.devtools.json {
        alias /usr/share/nginx/html/dev/.well-known/dev.com.chrome.devtools.json;
        add_header Cache-Control "public, max-age=86400";
    }
    location = /robots.txt {
        alias /usr/share/nginx/html/dev/robots-dev.txt;
        add_header Cache-Control "public, max-age=86400";
    }
    location = /sitemap.xml {
        alias /usr/share/nginx/html/dev/sitemap-dev.xml;
        add_header Cache-Control "public, max-age=86400";
        add_header Content-Type "application/xml; charset=utf-8";
    }

    include /etc/nginx/snippets/cache-rules.conf;

    location / {
        try_files $uri $uri/ /index.html;
    }

    error_page 404 /index.html;
}

server {
    listen 80;
    server_name mifi.bio www.mifi.bio;
    root /usr/share/nginx/html/bio;
    index index.html;

    # Map canonical .well-known paths to variant-specific files (alias cannot use variables)
    location = /.well-known/security.txt {
        alias /usr/share/nginx/html/bio/.well-known/bio.security.txt;
        add_header Cache-Control "public, max-age=86400";
    }
    location = /.well-known/appspecific/com.chrome.devtools.json {
        alias /usr/share/nginx/html/bio/.well-known/bio.com.chrome.devtools.json;
        add_header Cache-Control "public, max-age=86400";
    }
    location = /robots.txt {
        alias /usr/share/nginx/html/bio/robots-bio.txt;
        add_header Cache-Control "public, max-age=86400";
    }
    location = /sitemap.xml {
        alias /usr/share/nginx/html/bio/sitemap-bio.xml;
        add_header Cache-Control "public, max-age=86400";
        add_header Content-Type "application/xml; charset=utf-8";
    }

    include /etc/nginx/snippets/cache-rules.conf;

    location / {
        try_files $uri $uri/ /index.html;
    }

    error_page 404 /index.html;
}
