2021-12-13 20:49:56 +01:00
|
|
|
# vim: ft=nginx
|
|
|
|
server {
|
2021-12-18 00:03:22 +01:00
|
|
|
listen 80;
|
2021-12-13 20:49:56 +01:00
|
|
|
listen [::]:80;
|
|
|
|
|
2021-12-18 00:03:22 +01:00
|
|
|
|
|
|
|
# =====MATRIX WELL-KNOWN FILES=====
|
2021-12-13 20:49:56 +01:00
|
|
|
# Used for server federation
|
2021-12-18 00:03:22 +01:00
|
|
|
location = /.well-known/matrix/server {
|
2021-12-13 20:49:56 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2021-12-18 00:03:22 +01:00
|
|
|
location = /.well-known/matrix/client {
|
2021-12-13 20:49:56 +01:00
|
|
|
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;
|
|
|
|
}
|
2021-12-18 00:03:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
# =====FRONTEND HOSTING=====
|
|
|
|
location / {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
index index.html;
|
|
|
|
}
|
|
|
|
|
|
|
|
error_page 404 /404.html;
|
|
|
|
|
|
|
|
# redirect server error pages to the static page /50x.html
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
|
location = /50x.html {
|
|
|
|
root /usr/share/nginx/html;
|
|
|
|
}
|
2021-12-13 20:49:56 +01:00
|
|
|
}
|