{
    auto_https disable_redirects
    admin off
}

:80 {
    @music_health {
        host musicserver.internal.invalid
        path /health /health/db
    }
    handle @music_health {
        reverse_proxy 10.71.100.83:18080
    }
    @reports {
        host reports.secret-studio.ru reports001.secret-studio.ru
    }
    handle @reports {
        redir https://{host}{uri} 308
    }
    @access {
        host access.secret-studio.ru
    }
    handle @access {
        redir https://access.secret-studio.ru{uri} 308
    }
    handle {
        respond "not found" 404
    }
}

https://reports.secret-studio.ru {
    log {
        output stderr
        format json
    }

    @crawl_root path /
    handle @crawl_root {
        header Cache-Control "no-cache, max-age=0, must-revalidate"
        header X-Robots-Tag "index, follow"
        root * /srv/wg-paid/web-meta
        rewrite * /index.html
        file_server
    }

    @robots path /robots.txt
    handle @robots {
        header Cache-Control "no-cache, max-age=0, must-revalidate"
        root * /srv/wg-paid/web-meta
        file_server
    }

    @sitemap path /sitemap.xml
    handle @sitemap {
        header Cache-Control "no-cache, max-age=0, must-revalidate"
        root * /srv/wg-paid/web-meta
        rewrite * /sitemap-reports.xml
        file_server
    }

    handle {
        @latest path /latest /latest/*
        header @latest Cache-Control "no-cache, max-age=0, must-revalidate"
        @old path /old /old/*
        header @old Cache-Control "public, max-age=31536000, immutable"
        header X-Robots-Tag "index, follow"
        root * /srv/wg-paid/reports
        file_server
    }
}

https://reports001.secret-studio.ru {
    log {
        output stderr
        format json
    }

    @crawl_root path /
    handle @crawl_root {
        header Cache-Control "no-cache, max-age=0, must-revalidate"
        header X-Robots-Tag "index, follow"
        root * /srv/wg-paid/web-meta
        rewrite * /index.html
        file_server
    }

    @robots path /robots.txt
    handle @robots {
        header Cache-Control "no-cache, max-age=0, must-revalidate"
        root * /srv/wg-paid/web-meta
        file_server
    }

    @sitemap path /sitemap.xml
    handle @sitemap {
        header Cache-Control "no-cache, max-age=0, must-revalidate"
        root * /srv/wg-paid/web-meta
        rewrite * /sitemap-reports001.xml
        file_server
    }

    handle {
        @latest path /latest /latest/*
        header @latest Cache-Control "no-cache, max-age=0, must-revalidate"
        @old path /old /old/*
        header @old Cache-Control "public, max-age=31536000, immutable"
        header X-Robots-Tag "index, follow"
        root * /srv/wg-paid/reports
        file_server
    }
}

https://access.secret-studio.ru {
    @health path /health
    handle @health {
        respond "access-ok" 200
    }
    handle {
        respond 204
    }
}
