Compare commits

...
Sign in to create a new pull request.

6 commits

Author SHA1 Message Date
David Duque
6848e0056d
php-fpm: Guarantee that file namespaces differ 2021-11-17 22:05:31 +00:00
David Duque
ab31dc9011
Missed a semicolon 2021-11-17 21:12:30 +00:00
David Duque
ee2428742b
Clarify the names already used in .upstream.conf (2) 2021-11-17 20:12:27 +00:00
David Duque
84bfa84ff8
Clarify the names already used in .upstream.conf 2021-11-17 20:11:56 +00:00
David Duque
205b6784a1
Create two isolated php sockets. Leave the second one for user applications. 2021-11-17 20:08:30 +00:00
David Duque
24264ff852
Add .upstream.conf file if it doesn't exist 2021-11-17 19:44:06 +00:00
5 changed files with 31 additions and 5 deletions

View file

@ -31,7 +31,7 @@
fastcgi_param SCRIPT_FILENAME /usr/local/lib/z-push/index.php;
fastcgi_param PHP_VALUE "include_path=.:/usr/share/php:/usr/share/pear:/usr/share/awl/inc";
fastcgi_read_timeout 630;
fastcgi_pass php-fpm;
fastcgi_pass php-default;
# Outgoing mail also goes through this endpoint, so increase the maximum
# file upload limit to match the corresponding Postfix limit.
@ -41,7 +41,7 @@
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/lib/z-push/autodiscover/autodiscover.php;
fastcgi_param PHP_VALUE "include_path=.:/usr/share/php:/usr/share/pear:/usr/share/awl/inc";
fastcgi_pass php-fpm;
fastcgi_pass php-default;
}
# Disable viewing dotfiles (.htaccess, .svn, .git, etc.)

View file

@ -33,7 +33,7 @@
fastcgi_split_path_info ^/mail(/.*)()$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/lib/roundcubemail/$fastcgi_script_name;
fastcgi_pass php-fpm;
fastcgi_pass php-default;
# Outgoing mail also goes through this endpoint, so increase the maximum
# file upload limit to match the corresponding Postfix limit.
@ -60,7 +60,7 @@
index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/local/lib/owncloud/$1/$2;
fastcgi_pass php-fpm;
fastcgi_pass php-default;
}
}
location ~ ^(/cloud)((?:/ocs)?/[^/]+\.php)(/.*)?$ {
@ -77,7 +77,7 @@
fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
fastcgi_param MOD_X_ACCEL_REDIRECT_PREFIX /owncloud-xaccel;
fastcgi_read_timeout 630;
fastcgi_pass php-fpm;
fastcgi_pass php-default;
client_max_body_size 1G;
fastcgi_buffers 64 4K;
}

View file

@ -6,6 +6,11 @@
## If you modify any system configuration you are on
## your own --- please do not ask for help from us.
# This socket is reserved for Mail-in-a-Box-specific services
upstream php-default {
server unix:/var/run/php/php-default.sock;
}
upstream php-fpm {
server unix:/var/run/php/php{{phpver}}-fpm.sock;
}

View file

@ -118,6 +118,19 @@ def do_web_update(env):
# Build an nginx configuration file.
nginx_conf = open(os.path.join(os.path.dirname(__file__), "../conf/nginx-top.conf")).read()
nginx_conf = re.sub("{{phpver}}", get_php_version(), nginx_conf)
# Add upstream additions
nginx_upstream_include = os.path.join(env["STORAGE_ROOT"], "www", ".upstream.conf")
if not os.path.exists(nginx_upstream_include):
with open(nginx_upstream_include, "a+") as f:
f.writelines([
f"# Add your nginx-wide configurations here.\n",
"# The following names are already defined:\n\n",
"# # php-default: The php socket used for apps managed by the box. (Roundcube, Z-Push, Nextcloud, etc.) - DO NOT USE!\n",
"# # php-fpm: A php socket not managed by the box. Feel free to use it for your PHP applications\n"
])
nginx_conf += "\ninclude %s;\n" % (nginx_upstream_include)
# Load the templates.
template0 = open(os.path.join(os.path.dirname(__file__), "../conf/nginx.conf")).read()

View file

@ -95,6 +95,14 @@ else
pm.max_spare_servers=18
fi
# Duplicate the socket to isolate MiaB apps from user apps that happen to run php
cp /etc/php/$(php_version)/fpm/pool.d/www.conf /etc/php/$(php_version)/fpm/pool.d/miab.conf
management/editconf.py /etc/php/$(php_version)/fpm/pool.d/miab.conf -c ';' \
listen=/run/php/php-default.sock
sed -i 's/\[www\]/[miab]/' /etc/php/$(php_version)/fpm/pool.d/miab.conf
# Other nginx settings will be configured by the management service
# since it depends on what domains we're serving, which we don't know
# until mail accounts have been created.