Last active
November 20, 2022 09:01
-
-
Save hiway/6769abfc3758c9b8bbb8c2cb48eab7f3 to your computer and use it in GitHub Desktop.
Caddyfile for Mastodon 3.x and 4.x that also maps @[email protected] -> @[email protected]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
example.com { | |
header /.well-known/host-meta Access-Control-Allow-Origin * | |
respond /.well-known/host-meta `https://mastodon.example.com{uri}` | |
@webfinger { | |
path /.well-known/webfinger* | |
} | |
reverse_proxy @webfinger { | |
to http://localhost:3000 | |
header_up X-Forwarded-Port 443 | |
header_up X-Forwarded-Proto https | |
transport http { | |
keepalive 5s | |
keepalive_idle_conns 10 | |
} | |
} | |
} | |
mastodon.example.com { | |
@local { | |
file | |
not path / | |
} | |
@local_media { | |
path_regexp /system/(.*) | |
} | |
@streaming { | |
path /api/v1/streaming/* | |
} | |
@cache_control { | |
path_regexp ^/(emoji|packs|/system/accounts/avatars|/system/media_attachments/files) | |
} | |
root * /var/www/mastodon/live/public | |
log { | |
output file /var/log/caddy/mastodon.log | |
} | |
encode zstd gzip | |
handle_errors { | |
rewrite 500.html | |
file_server | |
} | |
header { | |
Strict-Transport-Security "max-age=31536000" | |
} | |
header /sw.js Cache-Control "public, max-age=0" | |
header @cache_control Cache-Control "public, max-age=31536000, immutable" | |
handle @local { | |
file_server | |
} | |
## If you've been migrated media from local to object storage, this navigate old URL to new one. | |
# redir @local_media https://yourobjectstorage.example.com/{http.regexp.1} permanent | |
reverse_proxy @streaming { | |
to http://localhost:4000 | |
transport http { | |
keepalive 5s | |
keepalive_idle_conns 10 | |
} | |
} | |
reverse_proxy { | |
to http://localhost:3000 | |
header_up X-Forwarded-Port 443 | |
header_up X-Forwarded-Proto https | |
transport http { | |
keepalive 5s | |
keepalive_idle_conns 10 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment