http://ru.homyk.space {
    redir https://ru.homyk.space{uri} permanent
}
https://ru.homyk.space {
    encode gzip

    handle /api/* {
        reverse_proxy backend:{$PORT}
    }

    handle_path /main/* {
        @images path_regexp \.(jpg|jpeg|png|webp|gif|svg)$
        header @images Cache-Control "public, max-age=604800"

        forward_auth backend:{$PORT} {
            uri /api/verify
            copy_headers Authorization
        }
        root * /srv/main
        file_server
    }

    handle_errors {
        @unauth expression {http.error.status_code} == 401
        redir @unauth / 302
    }
    handle {
        root * /srv/auth
        file_server {
            index login.html
        }
    }

    log {
        output file /data/logs/caddy.log {
            roll_size 5mb
            roll_keep 5
            roll_keep_for 72h
        }
        format json
    }
}
https://music.homyk.space {
    encode gzip

    # --- API ---
    handle {
        reverse_proxy koel:80
    }

    log {
        output file /data/logs/caddy1.log {
            roll_size 5mb
            roll_keep 5
            roll_keep_for 72h
        }
        format json
    }
}