Added proper matrix .well-known endpoints

pull/4/head
Jef Roosens 2021-12-13 20:49:56 +01:00
parent 31b1ef0949
commit 3728e2b24f
Signed by: Jef Roosens
GPG Key ID: B580B976584B5F30
2 changed files with 57 additions and 0 deletions

3
Dockerfile 100644
View File

@ -0,0 +1,3 @@
FROM nginx:1.21.4-alpine
COPY default.conf.template /etc/nginx/templates/default.conf.template

View File

@ -0,0 +1,54 @@
# vim: ft=nginx
server {
listen 80;
listen [::]:80;
# Used for server federation
location ~^/\.well-known/matrix/server$ {
charset utf-8;
default_type application/json;
if ($request_method = 'GET') {
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization';
return 200 '{"m.server":"${MATRIX_SERVER}"}';
}
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization';
add_header 'Content-Length' 0;
return 204;
}
return 405;
}
location ~^/\.well-known/matrix/client$ {
charset utf-8;
default_type application/json;
if ($request_method = 'GET') {
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization';
return 200 '{"m.homeserver":{"base_url":"${MATRIX_CLIENT_SERVER}"}}';
}
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin '*';
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'X-Requested-With, Content-Type, Authorization';
add_header 'Content-Length' 0;
return 204;
}
return 405;
}
}