:80 {
    root * /app/public

    handle_path /stats/* {
        rewrite * {uri}
        reverse_proxy https://tools-security.esy-web.dev {
            header_up Host tools-security.esy-web.dev
        }
    }

    handle /assets/perf.js {
        rewrite * /beacon.min.js
        reverse_proxy https://static.cloudflareinsights.com {
            header_up Host static.cloudflareinsights.com
        }
    }

    handle_path /sperf {
        rewrite * /cdn-cgi/rum
        reverse_proxy https://cloudflareinsights.com {
            header_up Host cloudflareinsights.com
        }
    }

    php_fastcgi php:9000 {
        trusted_proxies private_ranges
    }

    file_server

    encode gzip

    try_files {path} /index.php?{query}
}
