From ac969f05c93398948fa5bca86e8a8742c7fe3eeb Mon Sep 17 00:00:00 2001 From: glass beadian Date: Mon, 12 Oct 2026 13:16:45 +0000 Subject: [PATCH] Chat client hosted at chat.occupymedia.cc: Element + API on one host, hub welcome page --- infra/occupymedia/edge/nginx.conf | 59 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/infra/occupymedia/edge/nginx.conf b/infra/occupymedia/edge/nginx.conf index 2d25aed..add7fcc 100644 --- a/infra/occupymedia/edge/nginx.conf +++ b/infra/occupymedia/edge/nginx.conf @@ -102,22 +102,8 @@ http { listen 80; listen [::]:80; server_name chat.occupymedia.cc; - # Tunnel origin path: browsers hitting the bare server root get the branded - # client; the Matrix API flows through untouched. - location = / { - return 302 https://element.occupymedia.cc; - } - # Client discovery for @user:chat.occupymedia.cc logins (tuwunel does not serve it). - location = /.well-known/matrix/client { - default_type application/json; - return 200 '{"m.homeserver":{"base_url":"https://chat.occupymedia.cc"}}'; - } - location = /.well-known/matrix/server { - default_type application/json; - return 200 '{"m.server":"chat.occupymedia.cc:443"}'; - } - - location / { + # Tunnel origin path: the branded client on this host, Matrix API to the homeserver. + location ^~ /_matrix { proxy_pass http://100.117.210.52:6167; proxy_http_version 1.1; proxy_set_header Host $host; @@ -128,6 +114,17 @@ http { proxy_read_timeout 3600s; proxy_send_timeout 3600s; } + location ^~ /.well-known/matrix/ { + default_type application/json; + return 200 '{"m.homeserver":{"base_url":"https://chat.occupymedia.cc"}}'; + } + location / { + proxy_pass http://occ-element:80; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_read_timeout 60s; + } } server { @@ -138,19 +135,7 @@ http { ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem; - location = / { - return 302 https://element.occupymedia.cc; - } - location = /.well-known/matrix/client { - default_type application/json; - return 200 '{"m.homeserver":{"base_url":"https://chat.occupymedia.cc"}}'; - } - location = /.well-known/matrix/server { - default_type application/json; - return 200 '{"m.server":"chat.occupymedia.cc:443"}'; - } - - location / { + location ^~ /_matrix { proxy_pass http://100.117.210.52:6167; proxy_http_version 1.1; proxy_set_header Host $host; @@ -161,6 +146,22 @@ http { proxy_read_timeout 3600s; proxy_send_timeout 3600s; } + location = /.well-known/matrix/client { + default_type application/json; + return 200 '{"m.homeserver":{"base_url":"https://chat.occupymedia.cc"}}'; + } + location = /.well-known/matrix/server { + default_type application/json; + return 200 '{"m.server":"chat.occupymedia.cc:443"}'; + } + location / { + proxy_pass http://occ-element:80; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_read_timeout 60s; + } } server {