Skip to content

Commit

Permalink
Add matrix.aosus.org
Browse files Browse the repository at this point in the history
  • Loading branch information
FarisZR committed Oct 24, 2024
1 parent 25c54a3 commit a5f08cf
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions caddy/configs/matrix.caddyfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
matrix.aosus.org aosus.org:8448 {
# redirect image requests to discord CDN instead of uploading with a workaround for signed URL requirement (https://github.com/aosus/infrastructure-meta/issues/5)
handle /_matrix/media/*/download/aosus.org/discord_* {
header Access-Control-Allow-Origin *
# Remove path prefix
uri path_regexp ^/_matrix/media/.+/download/aosus\.org/discord_ "/https://cdn.discordapp.com/"
# The mxc patterns use | instead of /, so replace it first turning it into attachments/1234/5678/filename.png, and add "https://cdn.discordapp.com" so discord-resolver could fetch a signed url.
uri replace "%7C" /
reverse_proxy {
# reverse_proxy automatically includes the uri, so no {uri} at the end
to discord-resolver:3000
# Caddy doesn't set the Host header automatically when reverse proxying
# (because usually reverse proxies are local and don't care about Host headers)
header_up Host cdn.discordapp.com
}
}
# Do the same for thumbnails, but redirect to media.discordapp.net (which is Discord's thumbnailing server, and happens to use similar width/height params as Matrix)
# Alternatively, you can point this at cdn.discordapp.com too. Clients shouldn't mind even if they get a bigger image than they asked for.
handle /_matrix/media/*/thumbnail/aosus.org/discord_* {
header Access-Control-Allow-Origin *
uri path_regexp ^/_matrix/media/.+/thumbnail/aosus\.org/discord_ "/https://media.discordapp.net/"
uri replace "%7C" /
reverse_proxy {
to discord-resolver:3000
header_up Host media.discordapp.net
}
}
handle_errors {
# handle_errors is only triggerd on erros from Caddy and not the proxy, that's why we don't specifiy any errors here.
rewrite * /proxy_error_page.html
file_server {
root /srv/
}
}
reverse_proxy synapse:8008
encode zstd gzip
}

syncv3-matrix-proxy.aosus.org {
reverse_proxy sliding-sync:8008
encode zstd gzip
}

0 comments on commit a5f08cf

Please sign in to comment.