ticket.e-cosplay.fr {
    tls {
        dns cloudflare {{ cloudflare_api_token }}
    }

    @static path /logo.png /favicon.ico /favicon.png /marker.png /screen.png /manifest.json /site.webmanifest /sw.js /unavailable.html /workbox/* /idb/* /build/* /uploads/* /pwa/*
    handle @static {
        root * /var/www/e-ticket/public
        file_server
    }

    @maintenance file /var/www/e-ticket/public/.update
    handle @maintenance {
        root * /var/www/e-ticket/public
        rewrite * /maintenance.html
        file_server {
            status 503
        }
    }

    handle {
        root * /var/www/e-ticket/public
        php_fastcgi localhost:4578 localhost:4579 {
            root /app/public
            lb_policy round_robin
            trusted_proxies private_ranges
            dial_timeout 5s
            read_timeout 30s
            write_timeout 30s
        }
        file_server
        try_files {path} /index.php?{query}
    }

    handle_errors {
        @unavailable expression `{err.status_code} in [502, 503]`
        handle @unavailable {
            root * /var/www/e-ticket/public
            rewrite * /unavailable.html
            file_server
        }
    }

    encode gzip

    header {
        -Server
    }

    log {
        output file /var/log/caddy/ticket.e-cosplay.fr.log
    }
}
