From 8f96207830aca16f99a899888c43931c6beaa92a Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 10 Dec 2024 16:50:12 +0100 Subject: [PATCH] feat: Add support for nginx vhost config drop-ins Signed-off-by: Jonas --- .gitignore | 1 + data/nginx/vhost.d/.gitkeep | 0 docker-compose.yml | 3 +++ docs/customizing/nginx.md | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+) create mode 100644 data/nginx/vhost.d/.gitkeep create mode 100644 docs/customizing/nginx.md diff --git a/.gitignore b/.gitignore index 6072997..8ee89a7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.vscode +/data/nginx/vhost.d/ /data/ssl/ /data/shared/ /workspace/ diff --git a/data/nginx/vhost.d/.gitkeep b/data/nginx/vhost.d/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docker-compose.yml b/docker-compose.yml index 622c5de..6c5e016 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,6 +12,7 @@ services: volumes: - /var/run/docker.sock:/tmp/docker.sock:ro - ./data/ssl/:/etc/nginx/certs + - ./data/nginx/vhost.d/:/etc/nginx/vhost.d environment: DHPARAM_BITS: 2048 DHPARAM_GENERATION: "false" @@ -58,6 +59,8 @@ services: - phpmyadmin${DOMAIN_SUFFIX} - talk-signaling${DOMAIN_SUFFIX} - talk-recording${DOMAIN_SUFFIX} + extra_hosts: + - host.docker.internal:host-gateway haproxy: image: haproxy diff --git a/docs/customizing/nginx.md b/docs/customizing/nginx.md new file mode 100644 index 0000000..e6d40f7 --- /dev/null +++ b/docs/customizing/nginx.md @@ -0,0 +1,19 @@ +# Customize nginx config + +## Add custom config for a virtualhost config + +Add a config snippet to `data/nginx/vhost.d/`, it will be included in the respective vhost config automatically. + +For example to redirect all requests to `/apps.*/text` to a `vite serve` process on the docker host, add the following to `data/nginx/vhost.d/nextcloud.local`: + +``` +location ~* ^/apps.*/text/ { + rewrite ^/apps.*/text/(.*) /$1 break; + proxy_pass http://host.docker.internal:5173; + # fallback to nextcloud server if vite serve doesn't answer + error_page 502 = @fallback; +} +location @fallback { + proxy_pass http://nextcloud.local; +} +```