Merge pull request 'fix config' (#103) from use-direct-media into main
Reviewed-on: #103
This commit is contained in:
commit
661af6df73
2 changed files with 63 additions and 55 deletions
|
@ -182,64 +182,66 @@ in {
|
||||||
logFormat = pkgs.lib.mkForce "";
|
logFormat = pkgs.lib.mkForce "";
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
import baseConfig
|
import baseConfig
|
||||||
handle /_matrix/media/*/download/example.com/discord_* {
|
route {
|
||||||
header Access-Control-Allow-Origin *
|
handle /_matrix/media/*/download/matrix.chir.rs/discord_* {
|
||||||
# Remove path prefix
|
header Access-Control-Allow-Origin *
|
||||||
uri path_regexp ^/_matrix/media/.+/download/example\.com/discord_ /
|
# Remove path prefix
|
||||||
# The mxc patterns use | instead of /, so replace it first turning it into attachments/1234/5678/filename.png
|
uri path_regexp ^/_matrix/media/.+/download/matrix\.chir\.rs/discord_ /
|
||||||
uri replace "%7C" /
|
# The mxc patterns use | instead of /, so replace it first turning it into attachments/1234/5678/filename.png
|
||||||
reverse_proxy {
|
uri replace "%7C" /
|
||||||
# reverse_proxy automatically includes the uri, so no {uri} at the end
|
reverse_proxy {
|
||||||
to https://cdn.discordapp.com
|
# reverse_proxy automatically includes the uri, so no {uri} at the end
|
||||||
# Caddy doesn't set the Host header automatically when reverse proxying
|
to https://cdn.discordapp.com
|
||||||
# (because usually reverse proxies are local and don't care about Host headers)
|
# Caddy doesn't set the Host header automatically when reverse proxying
|
||||||
header_up Host cdn.discordapp.com
|
# (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.
|
# 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)
|
||||||
handle /_matrix/media/*/thumbnail/example.com/discord_* {
|
# 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.
|
||||||
header Access-Control-Allow-Origin *
|
handle /_matrix/media/*/thumbnail/matrix.chir.rs/discord_* {
|
||||||
uri path_regexp ^/_matrix/media/.+/thumbnail/example\.com/discord_ /
|
header Access-Control-Allow-Origin *
|
||||||
uri replace "%7C" /
|
uri path_regexp ^/_matrix/media/.+/thumbnail/matrix\.chir\.rs/discord_ /
|
||||||
reverse_proxy {
|
uri replace "%7C" /
|
||||||
to https://media.discordapp.net
|
reverse_proxy {
|
||||||
header_up Host media.discordapp.net
|
to https://media.discordapp.net
|
||||||
}
|
header_up Host media.discordapp.net
|
||||||
}
|
}
|
||||||
handle /_matrix/media/* {
|
}
|
||||||
uri * replace /unstable/fi.mau.msc2246/ /v1/
|
handle /_matrix/media/* {
|
||||||
reverse_proxy http://localhost:8008 {
|
uri * replace /unstable/fi.mau.msc2246/ /v1/
|
||||||
header_down Access-Control-Allow-Origin *
|
reverse_proxy http://localhost:8008 {
|
||||||
header_down Access-Control-Allow-Headers *
|
header_down Access-Control-Allow-Origin *
|
||||||
}
|
header_down Access-Control-Allow-Headers *
|
||||||
}
|
|
||||||
|
|
||||||
handle /_matrix/client/v3/logout/* {
|
|
||||||
reverse_proxy http://localhost:8008
|
|
||||||
}
|
|
||||||
|
|
||||||
handle /_matrix/* {
|
|
||||||
reverse_proxy {
|
|
||||||
to https://matrix.int.chir.rs
|
|
||||||
header_up Host {upstream_hostport}
|
|
||||||
|
|
||||||
transport http {
|
|
||||||
versions 1.1 2 3
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
handle /.well-known/matrix/server {
|
handle /_matrix/client/v3/logout/* {
|
||||||
header Access-Control-Allow-Origin *
|
reverse_proxy http://localhost:8008
|
||||||
header Content-Type application/json
|
}
|
||||||
respond "{ \"m.server\": \"matrix.chir.rs:443\" }" 200
|
|
||||||
}
|
|
||||||
|
|
||||||
handle /.well-known/matrix/client {
|
handle /_matrix/* {
|
||||||
header Access-Control-Allow-Origin *
|
reverse_proxy {
|
||||||
header Content-Type application/json
|
to https://matrix.int.chir.rs
|
||||||
respond "{ \"m.homeserver\": { \"base_url\": \"https://matrix.chir.rs\" } }" 200
|
header_up Host {upstream_hostport}
|
||||||
|
|
||||||
|
transport http {
|
||||||
|
versions 1.1 2 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handle /.well-known/matrix/server {
|
||||||
|
header Access-Control-Allow-Origin *
|
||||||
|
header Content-Type application/json
|
||||||
|
respond "{ \"m.server\": \"matrix.chir.rs:443\" }" 200
|
||||||
|
}
|
||||||
|
|
||||||
|
handle /.well-known/matrix/client {
|
||||||
|
header Access-Control-Allow-Origin *
|
||||||
|
header Content-Type application/json
|
||||||
|
respond "{ \"m.homeserver\": { \"base_url\": \"https://matrix.chir.rs\" } }" 200
|
||||||
|
}
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,7 +41,13 @@
|
||||||
missed.channel = -1;
|
missed.channel = -1;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
media_patterns.enabled = true;
|
media_patterns = {
|
||||||
|
enabled = true;
|
||||||
|
attachments = "mxc://matrix.chir.rs/discord_attachments|{{.ChannelID}}|{{.AttachmentID}}|{{.FileName}}";
|
||||||
|
emojis = "mxc://matrix.chir.rs/discord_emojis|{{.ID}}.{{.Ext}}";
|
||||||
|
stickers = "mxc://matrix.chir.rs/discord_stickers|{{.ID}}.{{.Ext}}";
|
||||||
|
avatars = "mxc://matrix.chir.rs/discord_avatars|{{.UserID}}|{{.AvatarID}}.{{.Ext}}";
|
||||||
|
};
|
||||||
encryption = {
|
encryption = {
|
||||||
allow = true;
|
allow = true;
|
||||||
appservice = true;
|
appservice = true;
|
||||||
|
|
Loading…
Reference in a new issue