From f3e35c8c8a88874b20c7142298c9089d9f4cdd0a Mon Sep 17 00:00:00 2001 From: Hardware Date: Sun, 6 May 2018 13:21:48 +0200 Subject: [PATCH] perf(): assets cache and php perf improvement --- Dockerfile | 4 ++-- rootfs/etc/nginx/nginx.conf | 32 ++++++++++++++++++++++++++++++-- rootfs/etc/php7/php-fpm.conf | 10 +++++----- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index c821dd7..2150fb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,8 +39,8 @@ RUN echo "@community https://nl.alpinelinux.org/alpine/v3.7/community" >> /etc/a && gpg --import RainLoop.asc \ && FINGERPRINT="$(LANG=C gpg --verify rainloop-community-latest.zip.asc rainloop-community-latest.zip 2>&1 \ | sed -n "s#Primary key fingerprint: \(.*\)#\1#p")" \ - && if [ -z "${FINGERPRINT}" ]; then echo "Warning! Invalid GPG signature!" && exit 1; fi \ - && if [ "${FINGERPRINT}" != "${GPG_FINGERPRINT}" ]; then echo "Warning! Wrong GPG fingerprint!" && exit 1; fi \ + && if [ -z "${FINGERPRINT}" ]; then echo "ERROR: Invalid GPG signature!" && exit 1; fi \ + && if [ "${FINGERPRINT}" != "${GPG_FINGERPRINT}" ]; then echo "ERROR: Wrong GPG fingerprint!" && exit 1; fi \ && mkdir /rainloop && unzip -q /tmp/rainloop-community-latest.zip -d /rainloop \ && find /rainloop -type d -exec chmod 755 {} \; \ && find /rainloop -type f -exec chmod 644 {} \; \ diff --git a/rootfs/etc/nginx/nginx.conf b/rootfs/etc/nginx/nginx.conf index 686beef..e41e921 100644 --- a/rootfs/etc/nginx/nginx.conf +++ b/rootfs/etc/nginx/nginx.conf @@ -56,6 +56,7 @@ http { root /rainloop; index index.php; charset utf-8; + client_max_body_size ; location ^~ /data { @@ -66,11 +67,38 @@ http { try_files $uri $uri/ index.php; } + # Assets cache control + # -------------------------------------- + location ~* \.(?:html|xml|json)$ { + expires -1; + } + + location ~* \.(?:css|js)$ { + expires 7d; + add_header Pragma public; + add_header Cache-Control "public"; + } + + location ~* \.(?:gif|jpe?g|png|ico|otf|eot|svg|ttf|woff|woff2)$ { + expires 30d; + add_header Pragma public; + add_header Cache-Control "public"; + } + + # PHP Backend + # -------------------------------------- location ~* \.php$ { + try_files $uri =404; + include fastcgi_params; + fastcgi_split_path_info ^(.+\.php)(/.*)$; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param HTTP_PROXY ""; fastcgi_index index.php; fastcgi_pass unix:/tmp/php-fpm.sock; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include /etc/nginx/fastcgi_params; + fastcgi_intercept_errors on; + fastcgi_request_buffering off; + fastcgi_param REMOTE_ADDR $http_x_real_ip; } } diff --git a/rootfs/etc/php7/php-fpm.conf b/rootfs/etc/php7/php-fpm.conf index c1f55da..db22e2b 100644 --- a/rootfs/etc/php7/php-fpm.conf +++ b/rootfs/etc/php7/php-fpm.conf @@ -1,13 +1,13 @@ [global] daemonize = no +error_log = /tmp/php_error.log [www] listen = /tmp/php-fpm.sock -pm = dynamic -pm.max_children = 5 -pm.start_servers = 2 -pm.min_spare_servers = 1 -pm.max_spare_servers = 3 +pm = ondemand +pm.max_children = 30 +pm.process_idle_timeout = 10s +pm.max_requests = 500 chdir = / php_admin_value[expose_php] = Off php_admin_value[post_max_size] =