Last active
June 30, 2024 03:03
-
-
Save yukimochi/bb7c90cbe628f216f821e835df1aeac1 to your computer and use it in GitHub Desktop.
For Mastodon Caddy Setting file. (Based on official Nginx configuration example) [Last Update: Mar 07, 2021]
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
https://yourdomain.example.com/ { | |
log / /var/log/caddy/mastodon.log "{combined}" { | |
rotate_age 90 | |
} | |
root /home/mastodon/live/public | |
gzip | |
header / { | |
Strict-Transport-Security "max-age=31536000" | |
} | |
header /sw.js Cache-Control "public, max-age=0" | |
header /emoji Cache-Control "public, max-age=31536000, immutable" | |
header /packs Cache-Control "public, max-age=31536000, immutable" | |
header /system/accounts/avatars Cache-Control "public, max-age=31536000, immutable" | |
header /system/media_attachments/files Cache-Control "public, max-age=31536000, immutable" | |
errors { | |
* 500.html | |
} | |
rewrite { | |
if {path} is / | |
to /proxy{path} | |
} | |
rewrite { | |
if {path} not_has /api/v1/streaming | |
to {path} /proxy{path} | |
} | |
proxy /proxy localhost:3000 { | |
without /proxy | |
transparent | |
websocket | |
} | |
proxy /api/v1/streaming localhost:4000 { | |
transparent | |
websocket | |
} | |
tls [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
{ | |
email [email protected] | |
} | |
https://yourdomain.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 * /home/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 | |
} | |
} | |
} |
For reference: my Caddyfile for Mastodon is online at https://blog.riemann.cc/digitalisation/2022/02/09/mastodon-setup-with-docker-and-caddy/
great guide -- I'm getting an error trying to generate the key's --
```
***@***.***:/docker/mastodon$ echo SECRET_KEY_BASE=$(docker-compose run
--rm web bundle exec rake secret)
sed -i -e "s/SECRET_KEY_BASE=/&${SECRET_KEY_BASE}/" .env.production
Creating network "mastodon_internal_network" with the default driver
Creating network "mastodon_external_network" with the default driver
Pulling db (postgres:14-alpine)...
Pulling redis (redis:7-alpine)...
Building web
ERROR: dockerfile parse error line 8: Unknown flag: link
SECRET_KEY_BASE=14-alpine: Pulling from library/postgres Digest:
sha256:f26094a8
84eb8861c0c9d23ad9699889a7d6e21af9de4c04c11645c4a1cdcac0 Status:
Downloaded newe r image for postgres:14-alpine
7-alpine: Pulling from library/redis Digest: sha2
56:2700d5097763fda285c463f4eefc3d0730a2df2a9d48e66707b19d5a5e5f23d4
Status: Down loaded newer image for
redis:7-alpine
***@***.***:/docker/mastodon$ echo SECRET_KEY_BASE=$(docker-compose run
--rm web bundle exec rake secret)
Building web
ERROR: dockerfile parse error line 8: Unknown flag: link
SECRET_KEY_BASE=
***@***.***:/docker/mastodon$ sudo nano docker-compose.yml
***@***.***:/docker/mastodon$ echo SECRET_KEY_BASE=$(docker-compose run
--rm web bundle exec rake secret)
…On Sat, Nov 19, 2022, 11:23 AM Robert Riemann ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
For reference: my Caddyfile for Mastodon is online at
https://blog.riemann.cc/digitalisation/2022/02/09/mastodon-setup-with-docker-and-caddy/
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/bb7c90cbe628f216f821e835df1aeac1#gistcomment-4375073>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARYHDOSF7H7DEOMLG3R2BULWJELI5BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVA2DOMRTHAYDKMVHORZGSZ3HMVZKMY3SMVQXIZI>
.
You are receiving this email because you commented on a thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
nevermidn, i got your guide confused with someone elses!
I'm using caddy v2 not v1 so your guide won't work with my setup,
thanks anyways
…On Sun, Nov 20, 2022 at 10:56 PM Ryan Naff ***@***.***> wrote:
great guide -- I'm getting an error trying to generate the key's --
```
***@***.***:/docker/mastodon$ echo SECRET_KEY_BASE=$(docker-compose
run --rm web bundle exec rake secret)
sed -i -e "s/SECRET_KEY_BASE=/&${SECRET_KEY_BASE}/" .env.production
Creating network "mastodon_internal_network" with the default driver
Creating network "mastodon_external_network" with the default driver
Pulling db (postgres:14-alpine)...
Pulling redis (redis:7-alpine)...
Building web
ERROR: dockerfile parse error line 8: Unknown flag: link
SECRET_KEY_BASE=14-alpine: Pulling from library/postgres Digest:
sha256:f26094a8
84eb8861c0c9d23ad9699889a7d6e21af9de4c04c11645c4a1cdcac0 Status:
Downloaded newe r image for postgres:14-alpine
7-alpine: Pulling from library/redis Digest: sha2
56:2700d5097763fda285c463f4eefc3d0730a2df2a9d48e66707b19d5a5e5f23d4
Status: Down loaded newer image for
redis:7-alpine
***@***.***:/docker/mastodon$ echo SECRET_KEY_BASE=$(docker-compose
run --rm web bundle exec rake secret)
Building web
ERROR: dockerfile parse error line 8: Unknown flag: link
SECRET_KEY_BASE=
***@***.***:/docker/mastodon$ sudo nano docker-compose.yml
***@***.***:/docker/mastodon$ echo SECRET_KEY_BASE=$(docker-compose
run --rm web bundle exec rake secret)
On Sat, Nov 19, 2022, 11:23 AM Robert Riemann ***@***.***>
wrote:
> ***@***.**** commented on this gist.
> ------------------------------
>
> For reference: my Caddyfile for Mastodon is online at
> https://blog.riemann.cc/digitalisation/2022/02/09/mastodon-setup-with-docker-and-caddy/
>
> —
> Reply to this email directly, view it on GitHub
> <https://gist.github.com/bb7c90cbe628f216f821e835df1aeac1#gistcomment-4375073>
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ARYHDOSF7H7DEOMLG3R2BULWJELI5BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVA2DOMRTHAYDKMVHORZGSZ3HMVZKMY3SMVQXIZI>
> .
> You are receiving this email because you commented on a thread.
>
> Triage notifications on the go with GitHub Mobile for iOS
> <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
> or Android
> <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
> .
>
>
One huge pro tip here is to run something like usermod -aG mastodon caddy
.. mine was refusing to load assets and static files and it took me ages to figure out it was a permissions issue :-)
are you using caddy v2?
If so, can you share with me your Caddyfile? Would be really helpful.
…On Mon, Nov 21, 2022 at 3:03 PM Peter Cooper ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
One huge pro tip here is to run something like usermod -aG mastodon caddy
.. mine was refusing to load assets and static files and it took me ages to
figure out it was a permissions issue :-)
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/bb7c90cbe628f216f821e835df1aeac1#gistcomment-4377119>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARYHDOVVQCNI7FLEBMCE6MLWJPWS7BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVA2DOMRTHAYDKMVHORZGSZ3HMVZKMY3SMVQXIZI>
.
You are receiving this email because you commented on a thread.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
@rnaff I've put it up at https://gist.github.com/peterc/fef53e6a308d412ab793148a1808977a - I think it's pretty much the same as the one here.
It's for v1 or v2 caddy?
…On Tue, Nov 22, 2022, 5:37 AM Peter Cooper ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
@rnaff <https://github.com/rnaff> I've put it up at
https://gist.github.com/peterc/fef53e6a308d412ab793148a1808977a - I think
it's pretty much the same as the one here.
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/bb7c90cbe628f216f821e835df1aeac1#gistcomment-4377869>
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ARYHDOTFBGCOG7Q3LQNDUKLWJS5ATBFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVA2DOMRTHAYDKMVHORZGSZ3HMVZKMY3SMVQXIZI>
.
You are receiving this email because you were mentioned.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>
.
FYI, line 14 on v2, seems incorrect. Its working for most clients, but certain libraries seem to be throwing strange errors (as they sometimes lack the last /
on the end of the URL).
Needs changing from path /api/v1/streaming/*
to path /api/v1/streaming*
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you ever get this working correctly?