# PXE HTTP server — serves boot files and WIM images
# Listens on port 8080 to avoid conflict with other services

server {
    listen 8080;
    server_name _;

    # iPXE boot script
    location /boot.ipxe {
        alias /srv/tftpboot/boot.ipxe;
        default_type text/plain;
    }

    # wimboot binary (iPXE Windows boot loader)
    location /wimboot {
        alias /srv/tftpboot/wimboot;
    }

    # WinPE boot files (BCD, boot.sdi, boot.wim)
    location /winpe/ {
        alias /srv/winpe/;
        sendfile on;
        tcp_nopush on;
    }

    # WIM images for deployment (multi-GB, needs efficient serving)
    location /images/ {
        alias /srv/images/;
        sendfile on;
        tcp_nopush on;
        aio threads;
        directio 4m;

        # Allow range requests for large WIM files
        max_ranges 32;
    }

    # Deployment scripts (PowerShell, diskpart, etc.)
    location /scripts/ {
        alias /srv/scripts/;
        default_type text/plain;
    }

    # Health check
    location /health {
        return 200 'pxe-http ok\n';
        default_type text/plain;
    }

    # Logging
    access_log /var/log/nginx/pxe-access.log;
    error_log /var/log/nginx/pxe-error.log;
}
