T-HUB/infra/occupymedia/edge/nginx.conf
glass beadian 9d42d61f6b edge: restyle the oCIS idp sign-in wall into the Hub palette
The sign-in page is served by oCIS's idp service, which the web theme.json
cannot touch. Inject hub-signin.css via sub_filter on /signin/ until oCIS
sits behind the Hub OIDC issuer (see docs/design/2026-10-13-files-oidc-sso.md).
2026-10-13 16:57:38 +00:00

410 lines
14 KiB
Nginx Configuration File

# occupymedia.cc edge — Cloudflare origin-pull terminator.
# Mirrors the tunnel ingress: host-routed reverse proxy in front of the apps.
# TLS: Let's Encrypt wildcard (dns-01). HTTP: redirect only.
worker_processes auto;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
server_tokens off;
map $http_upgrade $connection_upgrade {
default upgrade;
"" close;
}
# Lets the remote failover probe tell edge-served responses from tunnel-served.
add_header X-Served-By occ-edge always;
# HTTP: redirect everything to HTTPS.
server {
listen 80;
listen [::]:80;
return 301 https://$host$request_uri;
}
# Public apps. Origins mirror the cloudflared ingress:
# app -> occ-app web:3001 api -> occ-app api:3000
# tube -> occ-tube 9000 chat -> occ-chat 6167
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name app.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
client_max_body_size 512m;
location / {
proxy_pass http://web:3001;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name api.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
client_max_body_size 512m;
location / {
proxy_pass http://api:3000;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name tube.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
client_max_body_size 0;
location / {
proxy_pass http://100.92.231.98:9000;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
}
}
server {
listen 80;
listen [::]:80;
server_name chat.occupymedia.cc;
# 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;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
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"}}';
}
# Hub in-app Chat: sign-in bootstrap on Element's own origin (see hub-sso/chat-sso.html).
location = /hub-sso.html {
alias /opt/hub-sso/chat-sso.html;
default_type text/html;
add_header X-Served-By occ-edge always;
add_header Cache-Control "no-store" always;
add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; frame-ancestors https://app.occupymedia.cc" always;
}
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 {
listen 443 ssl;
listen [::]:443 ssl;
server_name chat.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
location ^~ /_matrix {
proxy_pass http://100.117.210.52:6167;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
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"}';
}
# Hub in-app Chat: sign-in bootstrap on Element's own origin (see hub-sso/chat-sso.html).
location = /hub-sso.html {
alias /opt/hub-sso/chat-sso.html;
default_type text/html;
add_header X-Served-By occ-edge always;
add_header Cache-Control "no-store" always;
add_header Content-Security-Policy "default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; frame-ancestors https://app.occupymedia.cc" always;
}
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 {
listen 443 ssl;
listen [::]:443 ssl;
server_name ping.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
return 200 "edge-ok";
}
# Hub branding overrides for the oCIS web client: theme json + assets are
# served by the edge; every other path proxies into oCIS. Also the tunnel
# origin path (:80) so both ingress paths get the same branding.
server {
listen 80;
listen [::]:80;
server_name files.occupymedia.cc;
location = /themes/owncloud/theme.json {
default_type application/json;
alias /opt/occ-brand/hub-theme.json;
}
location /themes/owncloud/assets/ {
alias /opt/occ-brand/;
}
location / {
proxy_pass http://192.168.13.210:9200;
# Hub in-app Drive frames oCIS web from app.occupymedia.cc: framing policy
# lives in oCIS csp.yaml (frame-ancestors); drop the legacy SAMEORIGIN.
proxy_hide_header X-Frame-Options;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
client_max_body_size 512m;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name files.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
client_max_body_size 512m;
location = /themes/owncloud/theme.json {
default_type application/json;
alias /opt/occ-brand/hub-theme.json;
}
location = /themes/owncloud/hub-signin.css {
default_type text/css;
alias /opt/occ-brand/hub-signin.css;
}
location /themes/owncloud/assets/ {
alias /opt/occ-brand/;
}
# The oCIS idp sign-in page ships ownCloud's light theme; restyle it into
# the Hub palette at the edge until oCIS sits behind the Hub OIDC issuer
# (docs/design/2026-10-13-files-oidc-sso.md).
location /signin/ {
proxy_pass http://192.168.13.210:9200;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
sub_filter '</head>' '<link rel="stylesheet" href="/themes/owncloud/hub-signin.css"></head>';
sub_filter_once on;
sub_filter_types text/html;
}
location / {
proxy_pass http://192.168.13.210:9200;
# Hub in-app Drive frames oCIS web from app.occupymedia.cc: framing policy
# lives in oCIS csp.yaml (frame-ancestors); drop the legacy SAMEORIGIN.
proxy_hide_header X-Frame-Options;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name office.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
location / {
proxy_pass http://192.168.13.210:9980;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name intake.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
client_max_body_size 20m;
location / {
proxy_pass http://occ-intake:3000;
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 {
listen 443 ssl;
listen [::]:443 ssl;
server_name element.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
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;
}
}
# Mastodon instance (social): web :3030 and streaming :4040 bound on the
# CT host LAN IP; federation clients hit the same vhost as browsers.
server {
listen 80;
listen [::]:80;
server_name social.occupymedia.cc;
location ~ ^/api/v1/streaming {
proxy_pass http://192.168.13.221:4040;
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 http;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
}
location / {
proxy_pass http://192.168.13.221:3030;
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 http;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
client_max_body_size 80m;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name social.occupymedia.cc;
ssl_certificate /etc/letsencrypt/live/occupymedia.cc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/occupymedia.cc/privkey.pem;
client_max_body_size 80m;
location ~ ^/api/v1/streaming {
proxy_pass http://192.168.13.221:4040;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
}
location / {
proxy_pass http://192.168.13.221:3030;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_buffering off;
}
}
# Everything else on this IP: drop the connection.
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_reject_handshake on;
}
}