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 diff --git a/webmails/rainloop/Dockerfile b/webmails/rainloop/Dockerfile index 8f77ab5c..fd4b7549 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 @@ -67,11 +68,12 @@ RUN apk add --no-cache \ && apk del unzip COPY start.py /start.py +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/config.py b/webmails/rainloop/config.py new file mode 100755 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..3905791f 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")) @@ -22,8 +23,11 @@ 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/") +subprocess.call(["/config.py"]) os.execv("/usr/sbin/nginx", ["nginx", "-g", "daemon off;"])