From f6c1ce23c6d065e5a77fc8d670d463994a14c430 Mon Sep 17 00:00:00 2001 From: ewilly Date: Sat, 16 Apr 2016 17:17:11 +0200 Subject: [PATCH] Upload limit #4 --- conf/nginx.conf | 4 ++-- manifest.json | 8 ++++++++ scripts/install | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 2517e61..34da5a8 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -4,7 +4,7 @@ location YNH_EXAMPLE_PATH { if ($scheme = http) { rewrite ^ https://$server_name$request_uri? permanent; } - client_max_body_size 10G; + client_max_body_size YNH_FILE_SIZE; index index.php; try_files $uri $uri/ index.php; @@ -13,7 +13,7 @@ location YNH_EXAMPLE_PATH { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; - fastcgi_param PHP_VALUE "upload_max_filesize = 2G \n post_max_size=2.1G"; + fastcgi_param PHP_VALUE "upload_max_filesize = YNH_FILE_SIZE \n post_max_size=YNH_POST_SIZE"; fastcgi_param REMOTE_USER $remote_user; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $request_filename; diff --git a/manifest.json b/manifest.json index 961676a..902bf0e 100644 --- a/manifest.json +++ b/manifest.json @@ -63,6 +63,14 @@ }, "choices": ["de","en","es","fr","it","nl","pl","pt","po","ro","ru"], "default": "en" + }, + { + "name": "filesize", + "ask": { + "en": "Define the file upload size limit", + "fr": "Définissez la taille limite de téléchargement" + }, + "default": "2G" } ] } diff --git a/scripts/install b/scripts/install index 88350fc..133eeba 100644 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,7 @@ path=$2 admin=$3 is_public=$4 default_lang=$5 +filesize=$6 # definie useful vars app=bozon @@ -67,6 +68,11 @@ sudo chown -R www-data: $data_path/uploads sudo chown -R www-data: $data_path/thumbs # configure nginx settings +## file upload size limit +postsize=$(echo "${filesize%?} + 0.1" | bc)$(echo ${filesize: -1}) +sudo sed -i "s@YNH_FILE_SIZE@$filesize@g" ../conf/nginx.conf +sudo sed -i "s@YNH_POST_SIZE@$postsize@g" ../conf/nginx.conf +## path folder_path=${path%/} sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf # if path is only / (without subfolder), add trailing slash to alias @@ -74,6 +80,7 @@ alias_path=$final_path [ "$path" == '/' ] && alias_path=$alias_path'/' sudo sed -i "s@YNH_EXAMPLE_ALIAS@$alias_path@g" ../conf/nginx.conf sudo sed -i "s@YNH_EXAMPLE_FOLDER@$folder_path@g" ../conf/nginx.conf + sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf # if app is private, remove url to SSOWat conf from skipped_uris