Skip to content

Instantly share code, notes, and snippets.

@tpharaoh
Created November 23, 2021 10:18
Show Gist options
  • Save tpharaoh/80ee16a02f9f7177455f7182c8fea57c to your computer and use it in GitHub Desktop.
Save tpharaoh/80ee16a02f9f7177455f7182c8fea57c to your computer and use it in GitHub Desktop.
caddyfile with mercure and php support
root@caddyMerc:/etc/caddy# more Caddyfile
# Learn how to configure the Mercure.rocks Hub on https://mercure.rocks/docs/hub/config
{
# Debug mode (disable it in production!)
{$DEBUG}
# HTTP/3 support
servers {
protocol {
experimental_http3
}
}
}
{$SERVER_NAME:domain.life}
file_server
log
route {
encode zstd gzip
root * /var/www/domain.life/public
@pwa expression `(
{header.Accept}.matches("\\btext/html\\b")
&& !{path}.matches("(?i)(?:^/docs|^/graphql|^/bundles/|^/_profiler|^/_wdt|\\.(?:json|html$|csv$|css$|js$|
ya?ml$|xml$))")
)
|| {path} == "/favicon.ico"
|| {path} == "/manifest.json"
|| {path} == "/robots.txt"
|| {path}.startsWith("/_next")
|| {path}.startsWith("/build")
|| {path}.startsWith("/sitemap")`
mercure {
anonymous
publisher_jwt !ChangeMe!
# Subscriber JWT key
subscriber_jwt !ChangeMe!
# Transport to use (default to Bolt)
transport_url {$MERCURE_TRANSPORT_URL:bolt://mercure.db}
# Publisher JWT key
# publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
# Subscriber JWT key
# subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
# Extra directives
{$MERCURE_EXTRA_DIRECTIVES}
}
push
# Add links to the API docs and to the Mercure Hub if not set explicitly (e.g. the PWA)
header ?Link `</docs.jsonld>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation", </.well-known/mercure>;
rel="mercure"`
# Disable Google FLOC tracking if not enabled explicitly: https://plausible.io/blog/google-floc
header ?Permissions-Policy "interest-cohort=()"
php_fastcgi unix//run/php/php7.4-fpm.sock
file_server
respond /healthz 200
respond "Not Found" 404
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment