{
    storage file_system {
        root ./data/caddy
    }
}
control.amanecerccu.com {
    encode zstd gzip
    handle /static/* {
        root * ../control/staticfiles
        uri strip_prefix /static
        file_server
    }
    handle {
        reverse_proxy 127.0.0.1:8766
    }
}

correo.amanecerccu.com {
    encode zstd gzip
    handle /static/* {
        root * ../control/staticfiles
        uri strip_prefix /static
        file_server
    }
    handle {
        reverse_proxy 127.0.0.1:8786
    }
}

mail.amanecerccu.com {
    redir https://correo.amanecerccu.com{uri}
}

http://192.168.1.64 {
    @downloads {
        method GET HEAD
        path /descargas/ /descargas/archivo/*
    }
    handle @downloads {
        reverse_proxy 127.0.0.1:8766 {
            header_up Host control.amanecerccu.com
            header_up X-Forwarded-Host control.amanecerccu.com
            header_up X-Forwarded-Proto https
        }
    }
    handle /static/* {
        root * ../control/staticfiles
        uri strip_prefix /static
        file_server
    }
    handle / {
        redir /descargas/ 302
    }
    handle {
        respond "Acceso local solo para descargas. Inicia sesion desde la app ACCRDP o https://control.amanecerccu.com." 404
    }
}
