From c4437e36391fa153ec5f974e1e1b86e3ffca5a97 Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 1 Dec 2022 20:02:31 +0100 Subject: [PATCH] Add nginx server --- matrix/docker-compose.yaml | 20 ++++++++++++++++++++ matrix/nginx/matrix.conf | 17 +++++++++++++++++ matrix/nginx/www/.well-known/matrix/client | 5 +++++ matrix/nginx/www/.well-known/matrix/server | 3 +++ 4 files changed, 45 insertions(+) create mode 100644 matrix/nginx/matrix.conf create mode 100644 matrix/nginx/www/.well-known/matrix/client create mode 100644 matrix/nginx/www/.well-known/matrix/server diff --git a/matrix/docker-compose.yaml b/matrix/docker-compose.yaml index a9044fc..ca71dc1 100644 --- a/matrix/docker-compose.yaml +++ b/matrix/docker-compose.yaml @@ -33,6 +33,26 @@ services: - "traefik.port=8008" - "traefik.docker.network=proxy" + well-kwown: + image: nginx:latest + restart: unless-stopped + networks: + - internal + - proxy + volumes: + - ./nginx/matrix.conf:/etc/nginx/conf.d/matrix.conf + - ./nginx/www:/var/www/ + labels: + - "traefik.enable=true" + - "traefik.http.middlewares.cors-headers.headers.accessControlAllowOriginList=*" + - "traefik.http.middlewares.cors-headers.headers.accessControlAllowHeaders=Origin, X-Requested-With, Content-Type, Accept, Authorization" + - "traefik.http.middlewares.cors-headers.headers.accessControlAllowMethods=GET, POST, PUT, DELETE, OPTIONS" + - "traefik.http.routers.matrix-wellknown.rule=Host(`matrix.mrdev023.fr`) && PathPrefix(`/.well-known/matrix`)" + - "traefik.http.routers.matrix-wellknown.tls=true" + - "traefik.http.routers.matrix-wellknown.tls.certresolver=sslResolver" + - "traefik.http.routers.matrix-wellknown.middlewares=cors-headers@docker" + - "traefik.docker.network=proxy" + volumes: db: diff --git a/matrix/nginx/matrix.conf b/matrix/nginx/matrix.conf new file mode 100644 index 0000000..c96544b --- /dev/null +++ b/matrix/nginx/matrix.conf @@ -0,0 +1,17 @@ +server { + listen 80 default_server; + server_name matrix.mrdev023.fr; + + # Traefik -> nginx -> synapse + location /_matrix { + proxy_pass http://synapse:8008; + proxy_set_header X-Forwarded-For $remote_addr; + client_max_body_size 128m; + } + + location /.well-known/matrix/ { + root /var/www/; + default_type application/json; + add_header Access-Control-Allow-Origin *; + } +} diff --git a/matrix/nginx/www/.well-known/matrix/client b/matrix/nginx/www/.well-known/matrix/client new file mode 100644 index 0000000..fddf165 --- /dev/null +++ b/matrix/nginx/www/.well-known/matrix/client @@ -0,0 +1,5 @@ +{ + "m.homeserver": { + "base_url": "https://matrix.mrdev023.fr" + } +} diff --git a/matrix/nginx/www/.well-known/matrix/server b/matrix/nginx/www/.well-known/matrix/server new file mode 100644 index 0000000..84e2bc7 --- /dev/null +++ b/matrix/nginx/www/.well-known/matrix/server @@ -0,0 +1,3 @@ +{ + "m.server": "matrix.mrdev023.fr:443" +}