I went and looked back at my old systemd service and I think have I had this issue before.
The old service set the user/group as www-data, but I had that commented out and I’m remembering it wasn’t working and I couldn’t figure it out, but once I removed that it worked.
I commented out the user/group and followed the errors until it worked then tried various combinations of the changes.
The current changes are:
- commented out
user
andgroup
- set
HOME
to the caddy users home - set
ProtectHome=false
(forgot to do that at the start for derpsin.space) - commented out
CapabilityBoundingSet
I’d like to figure out why the caddy user doesn’t have permissions, but at least it’s working right now.
So now the first three site blocks are working.
derpsin.space isn’t working, but I think it’s because I translated the config incorrectly.
Here is the old site block
derpsin.space {
root /home/csos95/dockerfiles/mastodon/public
gzip
header / {
Strict-Transport-Security "max-age=31536000;"
}
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 127.0.0.1:3000 {
without /proxy
transparent
websocket
}
proxy /api/v1/streaming 127.0.0.1:4000 {
transparent
websocket
}
}
Here is the new site block
derpsin.space {
root * /home/csos95/dockerfiles/mastodon/public
file_server
encode gzip
header Strict-Transport-Security "max-age=31536000;"
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"
handle_errors {
rewrite * /500.html
file_server
}
@rewrite1 {
path /
}
rewrite @rewrite1 /proxy{path}
@rewrite2 {
not path /api/v1/streaming
}
rewrite @rewrite2 /proxy{path}
@websockets {
header Connection *Upgrade*
header Upgrade websocket
}
reverse_proxy @websockets /proxy localhost:3000
}
EDIT:
Ok I found this thread and was able to fix my mastodon block.
Here’s the current one that works.
derpsin.space {
@try_masto {
file
}
@websockets {
header Connection *Upgrade*
header Upgrade websocket
}
root * /home/csos95/dockerfiles/mastodon/public
handle @try_masto {
file_server *
}
handle /api/v1/streaming* {
reverse_proxy @websockets localhost:4000
}
handle {
reverse_proxy localhost:3000
}
encode gzip
header {
Strict-Transport-Security "max-age=31536000;"
}
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"
handle_errors {
root * /home/csos95/dockerfiles/mastodon/public
rewrite 500.html
file_server
}
}