From 928901547346d8316592a38ecb22aa693603ad49 Mon Sep 17 00:00:00 2001 From: nd Date: Sat, 27 Apr 2019 21:47:33 +0200 Subject: [PATCH] added support for php ini values and custom vhost config --- README.md | 10 ++++++++++ tasks/php-fpm.yml | 11 +++++++++-- files/php-fpm/php.ini => templates/php-fpm/php.ini.j2 | 4 ++-- templates/vhost.j2 | 5 +++++ 4 files changed, 26 insertions(+), 4 deletions(-) rename files/php-fpm/php.ini => templates/php-fpm/php.ini.j2 (99%) diff --git a/README.md b/README.md index d243e50..893d484 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ vhosts: {} force_ssl: True # install php-fpm, setup a php-handler upstream and copy a php location snippet to include in configs +# either "False", "True" or a dict *phpconfig*, see below for definition php: False ``` @@ -65,6 +66,9 @@ backend: None # sets ssl certs to letsencrypt paths and enable letsencrypt for this vhost letsencrypt: False +# Array of custom config strings to add to the vhost config, the ";" is added after every entry +custom: [] + # array of locations, see below locations: [*locationconfig*, .. ] ``` @@ -78,3 +82,9 @@ match: '' alias: None ``` +**phpconfog**: +``` +ini: + post_max_size: 64M + upload_max_filesize: 64M +``` diff --git a/tasks/php-fpm.yml b/tasks/php-fpm.yml index 87f1c0d..be60a61 100644 --- a/tasks/php-fpm.yml +++ b/tasks/php-fpm.yml @@ -49,10 +49,17 @@ notify: - restart php-fpm +- set_fact: + phpinidefault: + post_max_size: 64M + upload_max_filesize: 64M +- set_fact: + phpini: "{{ phpinidefault|combine( {} if (nginx.php == True) else nginx.php.ini|d({}) ) }}" + - name: copy php-fpm php.ini - copy: + template: dest: /etc/php/7.0/fpm/php.ini - src: php-fpm/php.ini + src: php-fpm/php.ini.j2 mode: 0644 notify: - restart php-fpm diff --git a/files/php-fpm/php.ini b/templates/php-fpm/php.ini.j2 similarity index 99% rename from files/php-fpm/php.ini rename to templates/php-fpm/php.ini.j2 index 810c5a4..f78fa10 100644 --- a/files/php-fpm/php.ini +++ b/templates/php-fpm/php.ini.j2 @@ -653,7 +653,7 @@ auto_globals_jit = On ; Its value may be 0 to disable the limit. It is ignored if POST data reading ; is disabled through enable_post_data_reading. ; http://php.net/post-max-size -post_max_size = 8M +post_max_size = {{ phpini.post_max_size }} ; Automatically add files before PHP document. ; http://php.net/auto-prepend-file @@ -806,7 +806,7 @@ file_uploads = On ; Maximum allowed size for uploaded files. ; http://php.net/upload-max-filesize -upload_max_filesize = 2M +upload_max_filesize = {{ phpini.upload_max_filesize }} ; Maximum number of files that can be uploaded via a single request max_file_uploads = 20 diff --git a/templates/vhost.j2 b/templates/vhost.j2 index 617b8ac..94699c0 100644 --- a/templates/vhost.j2 +++ b/templates/vhost.j2 @@ -21,6 +21,11 @@ server { add_header {{ header }} {{ vhost.add_headers[header] }}; {% endfor %} + {% for c in vhost.custom|default([]) %} + {{ c }}; + {% endfor %} + + {% if vhost.backend|default(False) %} location / { proxy_pass {{ vhost.backend }};