From a9f4fc1b3c5dd3016ad19e6cdb3ed969a261cc75 Mon Sep 17 00:00:00 2001 From: Mario Jauvin Date: Mon, 31 Jan 2022 11:40:33 -0500 Subject: [PATCH 1/8] Use MESSAGE_SIZE_LIMIT in webmail container also The webmail container should use the same value as the front container. --- webmails/rainloop/Dockerfile | 5 +++-- webmails/rainloop/config.py | 15 +++++++++++++++ webmails/rainloop/config/nginx-rainloop.conf | 7 +++++-- webmails/rainloop/start.py | 1 + 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 webmails/rainloop/config.py diff --git a/webmails/rainloop/Dockerfile b/webmails/rainloop/Dockerfile index 8f77ab5c..3970a785 100644 --- a/webmails/rainloop/Dockerfile +++ b/webmails/rainloop/Dockerfile @@ -36,10 +36,11 @@ RUN apk add --no-cache \ && rm /etc/nginx/http.d/default.conf \ && rm /etc/php7/php-fpm.d/www.conf \ && mkdir -p /run/nginx \ - && mkdir -p /var/www/rainloop + && mkdir -p /var/www/rainloop \ + && mkdir -p /config # nginx / PHP config files -COPY config/nginx-rainloop.conf /etc/nginx/http.d/rainloop.conf +COPY config/nginx-rainloop.conf /config/nginx-rainloop.conf COPY config/php-rainloop.conf /etc/php7/php-fpm.d/rainloop.conf # Rainloop login diff --git a/webmails/rainloop/config.py b/webmails/rainloop/config.py new file mode 100644 index 00000000..88052961 --- /dev/null +++ b/webmails/rainloop/config.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 + +import os +import logging as log +import sys +from socrate import system, conf + +args = os.environ.copy() + +log.basicConfig(stream=sys.stderr, level=args.get("LOG_LEVEL", "WARNING")) + +# Build final configuration paths +conf.jinja("/config/nginx-rainloop.conf", args, "/etc/nginx/http.d/rainloop.conf") +if os.path.exists("/var/run/nginx.pid"): + os.system("nginx -s reload") diff --git a/webmails/rainloop/config/nginx-rainloop.conf b/webmails/rainloop/config/nginx-rainloop.conf index dfdbf8f7..be40e963 100644 --- a/webmails/rainloop/config/nginx-rainloop.conf +++ b/webmails/rainloop/config/nginx-rainloop.conf @@ -3,7 +3,7 @@ server { listen [::]:80 default_server; root /var/www/rainloop; - + # /dev/stdout (Default), , off access_log off; @@ -12,13 +12,16 @@ server { index index.php; + # set maximum body size to configured limit + client_max_body_size {{ MESSAGE_SIZE_LIMIT|int + 8388608 }}; + location / { try_files $uri /index.php?$query_string; } location ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.*)$; - + fastcgi_intercept_errors on; fastcgi_index index.php; diff --git a/webmails/rainloop/start.py b/webmails/rainloop/start.py index a52b70e9..7bb11a6a 100755 --- a/webmails/rainloop/start.py +++ b/webmails/rainloop/start.py @@ -26,4 +26,5 @@ conf.jinja("/defaults/php.ini", os.environ, "/etc/php7/php.ini") os.system("chown -R nginx:nginx /data") os.system("chmod -R a+rX /var/www/rainloop/") +subprocess.call(["/config.py"]) os.execv("/usr/sbin/nginx", ["nginx", "-g", "daemon off;"]) From 7dc98024478fa5ad9d4edd076bc5d8c18183a6df Mon Sep 17 00:00:00 2001 From: Mario Jauvin Date: Mon, 31 Jan 2022 12:19:15 -0500 Subject: [PATCH 2/8] Added subprocess import --- webmails/rainloop/start.py | 1 + 1 file changed, 1 insertion(+) diff --git a/webmails/rainloop/start.py b/webmails/rainloop/start.py index 7bb11a6a..e0a6e414 100755 --- a/webmails/rainloop/start.py +++ b/webmails/rainloop/start.py @@ -4,6 +4,7 @@ import os import shutil import logging as log import sys +import subprocess from socrate import system, conf log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING")) From 5a909bd45dafc64e698d2a48c7919833b482f5b8 Mon Sep 17 00:00:00 2001 From: Mario Jauvin Date: Mon, 31 Jan 2022 13:53:40 -0500 Subject: [PATCH 3/8] Add config.py and set permissions --- webmails/rainloop/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/webmails/rainloop/Dockerfile b/webmails/rainloop/Dockerfile index 3970a785..1d873f95 100644 --- a/webmails/rainloop/Dockerfile +++ b/webmails/rainloop/Dockerfile @@ -68,6 +68,7 @@ RUN apk add --no-cache \ && apk del unzip COPY start.py /start.py +COPY config.py /config.py EXPOSE 80/tcp VOLUME ["/data"] From 53a8543772f3680fde59ae697e7926f9e0834d6e Mon Sep 17 00:00:00 2001 From: Mario Jauvin Date: Mon, 31 Jan 2022 13:59:08 -0500 Subject: [PATCH 4/8] update permission --- webmails/rainloop/config.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 webmails/rainloop/config.py diff --git a/webmails/rainloop/config.py b/webmails/rainloop/config.py old mode 100644 new mode 100755 From db39d6b1e238f35ea1d9a9b08a6f25316ce74b8f Mon Sep 17 00:00:00 2001 From: Mario Jauvin Date: Mon, 31 Jan 2022 16:37:23 -0500 Subject: [PATCH 5/8] Set client_max_body_size in default nginx config file --- webmails/rainloop/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/webmails/rainloop/Dockerfile b/webmails/rainloop/Dockerfile index 1d873f95..bea4e434 100644 --- a/webmails/rainloop/Dockerfile +++ b/webmails/rainloop/Dockerfile @@ -39,6 +39,9 @@ RUN apk add --no-cache \ && mkdir -p /var/www/rainloop \ && mkdir -p /config +# set client_max_body_size to 0 so it can be overriden in rainloop +RUN sed -i -e 's/client_max_body_size 1m/client_max_body_size 0/' /etc/nginx/nginx.conf + # nginx / PHP config files COPY config/nginx-rainloop.conf /config/nginx-rainloop.conf COPY config/php-rainloop.conf /etc/php7/php-fpm.d/rainloop.conf From 4ea3b9522b8fef892971b274107fe6f959331fef Mon Sep 17 00:00:00 2001 From: Mario Jauvin Date: Mon, 31 Jan 2022 16:52:01 -0500 Subject: [PATCH 6/8] Add bugfix description --- towncrier/newsfragments/2207.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 towncrier/newsfragments/2207.bugfix diff --git a/towncrier/newsfragments/2207.bugfix b/towncrier/newsfragments/2207.bugfix new file mode 100644 index 00000000..f448f174 --- /dev/null +++ b/towncrier/newsfragments/2207.bugfix @@ -0,0 +1 @@ +Will update /etc/nginx/nginx.conf and /etc/nginx/http.d/rainloop.conf in webmail container to support MESSAGE_SIZE_LIMIT \ No newline at end of file From e47d9bf9beebd0f11c191e65c05f5251c08e4529 Mon Sep 17 00:00:00 2001 From: Mario Jauvin Date: Mon, 31 Jan 2022 21:44:59 -0500 Subject: [PATCH 7/8] Revert "Set client_max_body_size in default nginx config file" This reverts commit db39d6b1e238f35ea1d9a9b08a6f25316ce74b8f. --- webmails/rainloop/Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/webmails/rainloop/Dockerfile b/webmails/rainloop/Dockerfile index bea4e434..1d873f95 100644 --- a/webmails/rainloop/Dockerfile +++ b/webmails/rainloop/Dockerfile @@ -39,9 +39,6 @@ RUN apk add --no-cache \ && mkdir -p /var/www/rainloop \ && mkdir -p /config -# set client_max_body_size to 0 so it can be overriden in rainloop -RUN sed -i -e 's/client_max_body_size 1m/client_max_body_size 0/' /etc/nginx/nginx.conf - # nginx / PHP config files COPY config/nginx-rainloop.conf /config/nginx-rainloop.conf COPY config/php-rainloop.conf /etc/php7/php-fpm.d/rainloop.conf From 490e27e229f859854a335b46a44e25b342b02b29 Mon Sep 17 00:00:00 2001 From: Mario Jauvin Date: Sun, 13 Feb 2022 20:40:08 -0500 Subject: [PATCH 8/8] Start fastcgi process manager after config files updated --- webmails/rainloop/Dockerfile | 2 +- webmails/rainloop/start.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/webmails/rainloop/Dockerfile b/webmails/rainloop/Dockerfile index 1d873f95..fd4b7549 100644 --- a/webmails/rainloop/Dockerfile +++ b/webmails/rainloop/Dockerfile @@ -73,7 +73,7 @@ COPY config.py /config.py EXPOSE 80/tcp VOLUME ["/data"] -CMD php-fpm7 && /start.py +CMD /start.py HEALTHCHECK CMD curl -f -L http://localhost/ || exit 1 RUN echo $VERSION >> /version diff --git a/webmails/rainloop/start.py b/webmails/rainloop/start.py index e0a6e414..3905791f 100755 --- a/webmails/rainloop/start.py +++ b/webmails/rainloop/start.py @@ -23,6 +23,8 @@ os.makedirs(base + "configs", exist_ok=True) conf.jinja("/defaults/default.ini", os.environ, "/data/_data_/_default_/domains/default.ini") conf.jinja("/defaults/application.ini", os.environ, "/data/_data_/_default_/configs/application.ini") conf.jinja("/defaults/php.ini", os.environ, "/etc/php7/php.ini") +# Start the fastcgi process manager now that config files have been adjusted +os.system("php-fpm7") os.system("chown -R nginx:nginx /data") os.system("chmod -R a+rX /var/www/rainloop/")