From 55e3a317db18c822ee36641608384af3670243ee Mon Sep 17 00:00:00 2001 From: Kayou Date: Fri, 29 Mar 2019 22:18:08 +0100 Subject: [PATCH] Add default client_max_body_size --- conf/gitlab.rb | 1 + conf/nginx.conf | 4 +++- scripts/change_url | 4 +++- scripts/install | 7 ++++++- scripts/upgrade | 9 ++++++++- 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/conf/gitlab.rb b/conf/gitlab.rb index 7cf8018..153d3c6 100644 --- a/conf/gitlab.rb +++ b/conf/gitlab.rb @@ -20,6 +20,7 @@ EOS nginx['listen_port'] = __PORT__ nginx['listen_https'] = false nginx['listen_addresses'] = ["0.0.0.0", "[::]"] # listen on all IPv4 and IPv6 addresses +nginx['client_max_body_size'] = '__CLIENT_MAX_BODY_SIZE__' unicorn['port'] = __PORTUNICORN__ diff --git a/conf/nginx.conf b/conf/nginx.conf index e462a9c..46f5f04 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,9 +1,11 @@ location __PATH__/ { - proxy_pass http://localhost:__PORT__; + proxy_pass http://localhost:__PORT__; proxy_set_header Host $host; proxy_set_header X-Forwarded-Ssl on; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + client_max_body_size __CLIENT_MAX_BODY_SIZE__; + include conf.d/yunohost_panel.conf.inc; proxy_set_header Accept-Encoding ""; } diff --git a/scripts/change_url b/scripts/change_url index 56b6737..5179d29 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -32,6 +32,7 @@ config_path=$(ynh_app_setting_get $app config_path) port=$(ynh_app_setting_get "$app" web_port) portUnicorn=$(ynh_app_setting_get "$app" unicorn_port) unicorn_worker_processes=$(ynh_app_setting_get "$app" unicorn_worker_processes) +client_max_body_size=$(ynh_app_setting_get "$app" client_max_body_size) #================================================= # CHECK THE SYNTAX OF THE PATHS @@ -79,7 +80,7 @@ if [ $change_path -eq 1 ]; then domain="$old_domain" path_url="$new_path" # Create a dedicated nginx config - ynh_add_nginx_config + ynh_add_nginx_config $client_max_body_size fi # Change the domain for nginx @@ -113,6 +114,7 @@ ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" " ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb" ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb" ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb" +ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb" ynh_store_file_checksum "$config_path/gitlab.rb" diff --git a/scripts/install b/scripts/install index 82c192a..6e075cc 100644 --- a/scripts/install +++ b/scripts/install @@ -66,6 +66,9 @@ else unicorn_worker_processes=2 fi +# Could be an option? +client_max_body_size="250m" + path_url=$(ynh_normalize_url_path $path_url) # Register (book) web path @@ -84,6 +87,7 @@ ynh_app_setting_set $app final_path $final_path ynh_app_setting_set $app config_path $config_path ynh_app_setting_set $app architecture $architecture ynh_app_setting_set $app unicorn_worker_processes $unicorn_worker_processes +ynh_app_setting_set $app client_max_body_size $client_max_body_size #================================================= # STANDARD MODIFICATIONS @@ -122,6 +126,7 @@ ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" " ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb" ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb" ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb" +ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb" #================================================= # STORE THE CONFIG FILE CHECKSUM @@ -168,7 +173,7 @@ fi ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config $client_max_body_size #================================================= # SPECIFIC SETUP diff --git a/scripts/upgrade b/scripts/upgrade index 94c0c1f..170180c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,6 +29,7 @@ port=$(ynh_app_setting_get "$app" web_port) portUnicorn=$(ynh_app_setting_get "$app" unicorn_port) architecture=$(ynh_app_setting_get "$app" architecture) unicorn_worker_processes=$(ynh_app_setting_get "$app" unicorn_worker_processes) +client_max_body_size=$(ynh_app_setting_get "$app" client_max_body_size) #================================================= # ENSURE DOWNWARD COMPATIBILITY @@ -86,6 +87,11 @@ if [ -z "$architecture" ]; then ynh_app_setting_set $app architecture $architecture fi +# If client_max_body_size doesn't exist, create it +if [ -z "$client_max_body_size" ]; then + client_max_body_size="250m" +fi + # If domain doesn't exist, retrieve it if [ -z "$domain" ]; then domain=$(grep "external_url" "/etc/gitlab/gitlab.rb" | cut -d'/' -f3) # retrieve $domain from conf file @@ -168,6 +174,7 @@ ynh_replace_string "__GENERATED_EXTERNAL_URL__" "https://$domain${path_url%/}" " ynh_replace_string "__PORT__" "$port" "$config_path/gitlab.rb" ynh_replace_string "__PORTUNICORN__" "$portUnicorn" "$config_path/gitlab.rb" ynh_replace_string "__UNICORN_WORKER_PROCESSES__" "$unicorn_worker_processes" "$config_path/gitlab.rb" +ynh_replace_string "__CLIENT_MAX_BODY_SIZE__" "$client_max_body_size" "$config_path/gitlab.rb" ynh_store_file_checksum "$config_path/gitlab.rb" @@ -210,7 +217,7 @@ fi ynh_print_info "Configuring nginx web server..." # Create a dedicated nginx config -ynh_add_nginx_config +ynh_add_nginx_config $client_max_body_size #================================================= # GENERIC FINALIZATION