From 0c945c9516f135f21839e25e8799c973c9f599e4 Mon Sep 17 00:00:00 2001 From: Simon L Date: Fri, 19 May 2023 20:58:06 +0200 Subject: [PATCH 1/3] caddy - use correct syntax for trusted_proxies Signed-off-by: Simon L --- Containers/apache/start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Containers/apache/start.sh b/Containers/apache/start.sh index ccd1ca52..0e6ca101 100644 --- a/Containers/apache/start.sh +++ b/Containers/apache/start.sh @@ -39,9 +39,9 @@ echo "$CADDYFILE" > /Caddyfile # Change the trusted_proxies in case of reverse proxies if [ "$APACHE_PORT" != '443' ]; then - CADDYFILE="$(sed 's|# trusted_proxies placeholder|trusted_proxies private_ranges|' /Caddyfile)" + CADDYFILE="$(sed 's|# trusted_proxies placeholder|trusted_proxies static private_ranges|' /Caddyfile)" else - CADDYFILE="$(sed 's|trusted_proxies private_ranges|# trusted_proxies placeholder|' /Caddyfile)" + CADDYFILE="$(sed 's|trusted_proxies.*private_ranges|# trusted_proxies placeholder|' /Caddyfile)" fi echo "$CADDYFILE" > /Caddyfile From c84091cc0c5ad02b80b7dd7c4d05647767dfb0b5 Mon Sep 17 00:00:00 2001 From: Simon L Date: Sat, 20 May 2023 18:36:43 +0200 Subject: [PATCH 2/3] adjust things as discussed Signed-off-by: Simon L --- Containers/apache/Caddyfile | 41 ++++++++++++++++++++- Containers/apache/Dockerfile | 2 - Containers/apache/caddy-imports/collabora | 10 ----- Containers/apache/caddy-imports/notify-push | 5 --- Containers/apache/caddy-imports/onlyoffice | 8 ---- Containers/apache/caddy-imports/talk | 5 --- Containers/apache/nextcloud | 7 ---- Containers/apache/start.sh | 6 +-- 8 files changed, 42 insertions(+), 42 deletions(-) delete mode 100644 Containers/apache/caddy-imports/collabora delete mode 100644 Containers/apache/caddy-imports/notify-push delete mode 100644 Containers/apache/caddy-imports/onlyoffice delete mode 100644 Containers/apache/caddy-imports/talk delete mode 100644 Containers/apache/nextcloud diff --git a/Containers/apache/Caddyfile b/Containers/apache/Caddyfile index 6c815c8b..6006fee4 100644 --- a/Containers/apache/Caddyfile +++ b/Containers/apache/Caddyfile @@ -16,12 +16,49 @@ {$PROTOCOL}://{$NC_DOMAIN}:{$APACHE_PORT} { - # Bundled - import /caddy-imports/* + # Collabora + route /browser/* { + reverse_proxy {$COLLABORA_HOST}:9980 + } + route /hosting/* { + reverse_proxy {$COLLABORA_HOST}:9980 + } + route /cool/* { + reverse_proxy {$COLLABORA_HOST}:9980 + } + + # Notify Push + route /push/* { + uri strip_prefix /push + reverse_proxy {$NEXTCLOUD_HOST}:7867 + } + + # Onlyoffice + route /onlyoffice/* { + uri strip_prefix /onlyoffice + reverse_proxy {$ONLYOFFICE_HOST}:80 { + header_up X-Forwarded-Host {http.request.host}/onlyoffice + header_up X-Forwarded-Proto https + } + } + + # Talk + route /standalone-signaling/* { + uri strip_prefix /standalone-signaling + reverse_proxy {$TALK_HOST}:8081 + } # Others import /mnt/data/caddy-imports/* + # Nextcloud + route { + rewrite /.well-known/carddav /remote.php/dav + rewrite /.well-known/caldav /remote.php/dav + header Strict-Transport-Security max-age=31536000; + reverse_proxy localhost:8000 + } + # TLS options tls { issuer acme { diff --git a/Containers/apache/Dockerfile b/Containers/apache/Dockerfile index f9cea6f1..c96e5470 100644 --- a/Containers/apache/Dockerfile +++ b/Containers/apache/Dockerfile @@ -7,8 +7,6 @@ COPY --from=caddy /usr/bin/caddy /usr/bin/caddy COPY --chown=33:33 Caddyfile /Caddyfile COPY --chmod=664 nextcloud.conf /usr/local/apache2/conf/nextcloud.conf -COPY --chmod=664 nextcloud /nextcloud -COPY --chmod=664 caddy-imports/* /caddy-imports/ COPY --chmod=664 supervisord.conf /supervisord.conf COPY --chmod=775 start.sh /start.sh COPY --chmod=775 healthcheck.sh /healthcheck.sh diff --git a/Containers/apache/caddy-imports/collabora b/Containers/apache/caddy-imports/collabora deleted file mode 100644 index 89d44bae..00000000 --- a/Containers/apache/caddy-imports/collabora +++ /dev/null @@ -1,10 +0,0 @@ -# Collabora -route /browser/* { - reverse_proxy {$COLLABORA_HOST}:9980 -} -route /hosting/* { - reverse_proxy {$COLLABORA_HOST}:9980 -} -route /cool/* { - reverse_proxy {$COLLABORA_HOST}:9980 -} diff --git a/Containers/apache/caddy-imports/notify-push b/Containers/apache/caddy-imports/notify-push deleted file mode 100644 index 6aaf6d6a..00000000 --- a/Containers/apache/caddy-imports/notify-push +++ /dev/null @@ -1,5 +0,0 @@ -# Notify Push -route /push/* { - uri strip_prefix /push - reverse_proxy {$NEXTCLOUD_HOST}:7867 -} diff --git a/Containers/apache/caddy-imports/onlyoffice b/Containers/apache/caddy-imports/onlyoffice deleted file mode 100644 index e1994139..00000000 --- a/Containers/apache/caddy-imports/onlyoffice +++ /dev/null @@ -1,8 +0,0 @@ -# Onlyoffice -route /onlyoffice/* { - uri strip_prefix /onlyoffice - reverse_proxy {$ONLYOFFICE_HOST}:80 { - header_up X-Forwarded-Host {http.request.host}/onlyoffice - header_up X-Forwarded-Proto https - } -} diff --git a/Containers/apache/caddy-imports/talk b/Containers/apache/caddy-imports/talk deleted file mode 100644 index b7024cde..00000000 --- a/Containers/apache/caddy-imports/talk +++ /dev/null @@ -1,5 +0,0 @@ -# Talk -route /standalone-signaling/* { - uri strip_prefix /standalone-signaling - reverse_proxy {$TALK_HOST}:8081 -} diff --git a/Containers/apache/nextcloud b/Containers/apache/nextcloud deleted file mode 100644 index a0c2c80a..00000000 --- a/Containers/apache/nextcloud +++ /dev/null @@ -1,7 +0,0 @@ -# Nextcloud -route /* { - rewrite /.well-known/carddav /remote.php/dav - rewrite /.well-known/caldav /remote.php/dav - header Strict-Transport-Security max-age=31536000; - reverse_proxy localhost:8000 -} diff --git a/Containers/apache/start.sh b/Containers/apache/start.sh index 0e6ca101..8bc1805f 100644 --- a/Containers/apache/start.sh +++ b/Containers/apache/start.sh @@ -45,9 +45,6 @@ else fi echo "$CADDYFILE" > /Caddyfile -# Overwrite nextcloud conf -cat /nextcloud > /mnt/data/caddy-imports/nextcloud - # Fix the Caddyfile format caddy fmt --overwrite /Caddyfile @@ -57,6 +54,9 @@ mkdir -p /mnt/data/caddy/ # Add caddy import path mkdir -p /mnt/data/caddy-imports +# Makre sure that the caddy-imports dir is not empty +echo "" > /mnt/data/caddy-imports/empty + # Fix apache startup rm -f /usr/local/apache2/logs/httpd.pid From a620640fa778678386aabda8455a7e3492301ecd Mon Sep 17 00:00:00 2001 From: Simon L Date: Sat, 20 May 2023 18:41:12 +0200 Subject: [PATCH 3/3] fix detail Signed-off-by: Simon L --- Containers/apache/start.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Containers/apache/start.sh b/Containers/apache/start.sh index 8bc1805f..1806f7b4 100644 --- a/Containers/apache/start.sh +++ b/Containers/apache/start.sh @@ -54,6 +54,9 @@ mkdir -p /mnt/data/caddy/ # Add caddy import path mkdir -p /mnt/data/caddy-imports +# Remove falsely added Nextcloud conf +rm -f /mnt/data/caddy-imports/nextcloud + # Makre sure that the caddy-imports dir is not empty echo "" > /mnt/data/caddy-imports/empty