From 7029f6eb8586144a8fdf49773440d3f23927c3fa Mon Sep 17 00:00:00 2001 From: --help Date: Sat, 12 Aug 2023 11:30:01 +0200 Subject: [PATCH 01/65] Add error 404 code --- conf/nginx.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/conf/nginx.conf b/conf/nginx.conf index 9f696ae..f446dd0 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -20,6 +20,12 @@ location __PATH__/ { access_log off; } + error_page 404 error/404.html; + location = __PATH__/error/404.html { + internal; + } + + # Deny access to hidden files and directories location ~ ^__PATH__/(.+/|)\.(?!well-known\/) { deny all; From 6095c6c21f2529917deecf8f55c58b5d4c04cff2 Mon Sep 17 00:00:00 2001 From: --help Date: Sat, 12 Aug 2023 13:21:59 +0200 Subject: [PATCH 02/65] Update default config about the http error --- conf/nginx.conf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index f446dd0..7e27119 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,7 +6,7 @@ location __PATH__/ { # Default indexes and catch-all index index.html index.php; - try_files $uri $uri/ __PATH__/index.php?$args; + try_files $uri $uri/ __PATH__/index.php?$args =404; # Prevent useless logs location = __PATH__/favicon.ico { @@ -20,12 +20,12 @@ location __PATH__/ { access_log off; } - error_page 404 error/404.html; + # Build error access + error_page 404 /404.html; location = __PATH__/error/404.html { internal; } - # Deny access to hidden files and directories location ~ ^__PATH__/(.+/|)\.(?!well-known\/) { deny all; From 7083a50ec88a8f8d7e8f7890a39c01d189d031a1 Mon Sep 17 00:00:00 2001 From: --help Date: Sat, 12 Aug 2023 13:29:35 +0200 Subject: [PATCH 03/65] Update app version --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index e0085f2..f17289e 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "My Webapp" description.en = "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files" description.fr = "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP" -version = "1.0~ynh14" +version = "1.0~ynh15" maintainers = [] From 4255b0a4bc9ef98fb74b2bdb954c8cce8503c696 Mon Sep 17 00:00:00 2001 From: --help Date: Sat, 12 Aug 2023 16:52:25 +0200 Subject: [PATCH 04/65] Add code error 50X --- conf/nginx.conf | 5 +++++ manifest.toml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7e27119..45d178d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -25,6 +25,11 @@ location __PATH__/ { location = __PATH__/error/404.html { internal; } + error_page 500 502 503 /50x.html; + location = __PATH__/error/50x.html { + internal; + } + # Deny access to hidden files and directories location ~ ^__PATH__/(.+/|)\.(?!well-known\/) { diff --git a/manifest.toml b/manifest.toml index f17289e..97fd1e1 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "My Webapp" description.en = "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files" description.fr = "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP" -version = "1.0~ynh15" +version = "1.0~ynh16" maintainers = [] From 718c0dbdd863adfd700a02fea863b22b9a0c40bc Mon Sep 17 00:00:00 2001 From: --help Date: Sat, 12 Aug 2023 17:58:39 +0200 Subject: [PATCH 05/65] Fix path error_page --- conf/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 45d178d..ac5da7f 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -21,7 +21,7 @@ location __PATH__/ { } # Build error access - error_page 404 /404.html; + error_page 404 /error/404.html; location = __PATH__/error/404.html { internal; } From 140562326ec380d904ed7840572af118ba17db34 Mon Sep 17 00:00:00 2001 From: --help Date: Sun, 13 Aug 2023 09:08:31 +0200 Subject: [PATCH 06/65] Try to config the 404.html file Remove error page 50X --- conf/nginx.conf | 5 ----- config_panel.toml | 8 ++++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index ac5da7f..22dd70d 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -25,11 +25,6 @@ location __PATH__/ { location = __PATH__/error/404.html { internal; } - error_page 500 502 503 /50x.html; - location = __PATH__/error/50x.html { - internal; - } - # Deny access to hidden files and directories location ~ ^__PATH__/(.+/|)\.(?!well-known\/) { diff --git a/config_panel.toml b/config_panel.toml index b229f0f..aa5b049 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -18,6 +18,14 @@ name = "My Webapp configuration" visible = "with_sftp" help = "If a password already exist, leave blank and it will not be replaced." + [main.error] + name = "Html Custom error" + + [main.error.setting] + ask = "HTML Path" + type = "string" + default = "/404.html" + [main.php_fpm_config] name = "PHP-FPM configuration" From 8b30a536cba3502384a434a19181239b3d87d70e Mon Sep 17 00:00:00 2001 From: --help Date: Sun, 13 Aug 2023 09:39:48 +0200 Subject: [PATCH 07/65] Try to setup the error code upgrade --- config_panel.toml | 2 +- manifest.toml | 8 +++++++- scripts/upgrade | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index aa5b049..113b804 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -21,7 +21,7 @@ name = "My Webapp configuration" [main.error] name = "Html Custom error" - [main.error.setting] + [main.error.errorfile] ask = "HTML Path" type = "string" default = "/404.html" diff --git a/manifest.toml b/manifest.toml index 97fd1e1..32879ee 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "My Webapp" description.en = "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files" description.fr = "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP" -version = "1.0~ynh16" +version = "1.0~ynh17" maintainers = [] @@ -58,6 +58,12 @@ ram.runtime = "50M" type = "boolean" default = false + [install.errorfile] + ask.en = "Define a path about the 404 error page" + ask.fr = "Definir un chemin pour la page d'erreur 404" + type = "path" + default = "/404.html" + [resources] [resources.system_user] diff --git a/scripts/upgrade b/scripts/upgrade index 19a6549..bf15aaa 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -90,6 +90,11 @@ then YNH_PHP_VERSION="$phpversion" fi +if [ $errorfile ] +then + echo add the error config +fi + # Create a dedicated NGINX config ynh_add_nginx_config ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf" From b863da7cff82ffb3f4aaa2636c50bc055497ba0b Mon Sep 17 00:00:00 2001 From: --help Date: Sun, 13 Aug 2023 10:47:43 +0200 Subject: [PATCH 08/65] Update upgrade to set the code error --- conf/nginx-code-error.conf | 5 +++++ manifest.toml | 2 +- scripts/upgrade | 10 ++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 conf/nginx-code-error.conf diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf new file mode 100644 index 0000000..dba1050 --- /dev/null +++ b/conf/nginx-code-error.conf @@ -0,0 +1,5 @@ +# Build error access +error_page 404 /error/404.html; +location = __PATH__/error/404.html { + internal; +} \ No newline at end of file diff --git a/manifest.toml b/manifest.toml index 32879ee..10be47a 100644 --- a/manifest.toml +++ b/manifest.toml @@ -58,7 +58,7 @@ ram.runtime = "50M" type = "boolean" default = false - [install.errorfile] + [install.codeerror] ask.en = "Define a path about the 404 error page" ask.fr = "Definir un chemin pour la page d'erreur 404" type = "path" diff --git a/scripts/upgrade b/scripts/upgrade index bf15aaa..234636c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,6 +56,11 @@ if [ -z "$phpversion" ]; then ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion fi +# If $codeerror doesn't exist, create it. We assume it is the default system one. +if [ -z "$codeerror" ]; then + codeerror=$(ynh_app_setting_get --app=$app --key=codeerror) +fi + # Delete old user if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] then @@ -90,9 +95,10 @@ then YNH_PHP_VERSION="$phpversion" fi -if [ $errorfile ] +if [ $codeerror ] then - echo add the error config + echo add the error config + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error.conf" fi # Create a dedicated NGINX config From adb9f09d60481eec481a58e2b38829f9931c5ead Mon Sep 17 00:00:00 2001 From: --help Date: Tue, 15 Aug 2023 15:09:55 +0200 Subject: [PATCH 09/65] Change the upgrade config Update the post-install documentation --- doc/POST_INSTALL_fr.md | 7 +++++++ scripts/upgrade | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md index 87467a7..3fda038 100644 --- a/doc/POST_INSTALL_fr.md +++ b/doc/POST_INSTALL_fr.md @@ -5,3 +5,10 @@ Si vous avez demandé une base de données MYSQL, voici les informations de cett - Mot de passe : __DB_PWD__ La documentation ci-dessous contient également les informations pour se connecter en SSH et modifier le contenu du site web. + + + +Si vous avez activé la gestion du code d'erreur 404, vous pouvez placer un fichier 404.html, à la racine de votre +répertoire, le fichier sera alors reconnu par Nginx. + +Il est sinon possible de modifier le chemin dans l'administration afin de spécifier un repertoire. diff --git a/scripts/upgrade b/scripts/upgrade index 234636c..99ee670 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,7 +57,7 @@ if [ -z "$phpversion" ]; then fi # If $codeerror doesn't exist, create it. We assume it is the default system one. -if [ -z "$codeerror" ]; then +if [ -n "$(ynh_app_setting_get --app=$app --key=codeerror)" ]; then codeerror=$(ynh_app_setting_get --app=$app --key=codeerror) fi @@ -95,7 +95,8 @@ then YNH_PHP_VERSION="$phpversion" fi -if [ $codeerror ] +# Add the config error code +if [ -n "$(ynh_app_setting_get --app=$app --key=codeerror)" ]; then echo add the error config ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error.conf" From 74526f2e537ed660233fd6abc512ffa28f78237b Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Wed, 16 Aug 2023 18:16:57 +0200 Subject: [PATCH 10/65] Remove duplicate nginx config Clear manifest data, option only available with the config panel Try to setup the config panel Set the version number --- conf/nginx.conf | 6 ------ config_panel.toml | 17 +++++++++++++---- manifest.toml | 8 +------- scripts/config | 5 +++++ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 22dd70d..e522e75 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -20,12 +20,6 @@ location __PATH__/ { access_log off; } - # Build error access - error_page 404 /error/404.html; - location = __PATH__/error/404.html { - internal; - } - # Deny access to hidden files and directories location ~ ^__PATH__/(.+/|)\.(?!well-known\/) { deny all; diff --git a/config_panel.toml b/config_panel.toml index 113b804..375b895 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -18,13 +18,22 @@ name = "My Webapp configuration" visible = "with_sftp" help = "If a password already exist, leave blank and it will not be replaced." - [main.error] + [main.code_error] name = "Html Custom error" - [main.error.errorfile] - ask = "HTML Path" + [main.code_error.custom_error_file] + ask = "Activate the custom error file use" + type = "boolean" + default = false + # default = "/404.html" + help = "you enable this, you can create a custom `404.html` file at the root of your app to act as the custom 404 error page" + + [main.code_error.path_folder] + ask = "Specifie folder where your error file are sto" type = "string" - default = "/404.html" + default = "/" + help = "You can set where your error file are store in your www folder." + [main.php_fpm_config] name = "PHP-FPM configuration" diff --git a/manifest.toml b/manifest.toml index 10be47a..f17289e 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "My Webapp" description.en = "Custom Web app with SFTP access to serve static (HTML, CSS, JS) and PHP files" description.fr = "Application Web personnalisée avec accès SFTP pour servir des fichiers statiques (HTML, CSS, JS) et PHP" -version = "1.0~ynh17" +version = "1.0~ynh15" maintainers = [] @@ -58,12 +58,6 @@ ram.runtime = "50M" type = "boolean" default = false - [install.codeerror] - ask.en = "Define a path about the 404 error page" - ask.fr = "Definir un chemin pour la page d'erreur 404" - type = "path" - default = "/404.html" - [resources] [resources.system_user] diff --git a/scripts/config b/scripts/config index 21b6f17..319756e 100644 --- a/scripts/config +++ b/scripts/config @@ -148,6 +148,11 @@ ynh_app_config_apply() { ynh_system_user_del_group --username=$app --groups="sftp.app" fi + if [ "${changed[errorfile]}" == "true" ] + then + echo Update error nginx config + fi + if [ "$phpversion" != "none" ] then ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint From 8fe710187a7c53ec6cad9a6dacc7f6a1cf7039a4 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Wed, 16 Aug 2023 18:36:04 +0200 Subject: [PATCH 11/65] Update install/upgrade --- config_panel.toml | 12 +++++------- scripts/install | 6 ++++++ scripts/upgrade | 11 +++++------ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 375b895..48c03ed 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -25,15 +25,13 @@ name = "My Webapp configuration" ask = "Activate the custom error file use" type = "boolean" default = false - # default = "/404.html" help = "you enable this, you can create a custom `404.html` file at the root of your app to act as the custom 404 error page" - [main.code_error.path_folder] - ask = "Specifie folder where your error file are sto" - type = "string" - default = "/" - help = "You can set where your error file are store in your www folder." - + # [main.code_error.path_folder] + # ask = "Specifie folder where your error file are sto" + # type = "string" + # default = "/" + # help = "You can set where your error file are store in your www folder." [main.php_fpm_config] name = "PHP-FPM configuration" diff --git a/scripts/install b/scripts/install index a976713..d671e86 100644 --- a/scripts/install +++ b/scripts/install @@ -63,6 +63,12 @@ then YNH_PHP_VERSION="$phpversion" fi +if [ ! $custom_error_file ] +then + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + CUSTOM_ERROR_FILE="$custom_error_file" +fi + # Create a dedicated NGINX config ynh_add_nginx_config ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf" diff --git a/scripts/upgrade b/scripts/upgrade index 99ee670..a9beb78 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,9 +56,9 @@ if [ -z "$phpversion" ]; then ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion fi -# If $codeerror doesn't exist, create it. We assume it is the default system one. -if [ -n "$(ynh_app_setting_get --app=$app --key=codeerror)" ]; then - codeerror=$(ynh_app_setting_get --app=$app --key=codeerror) +# If custom_error_files doesn't exist, create it. We assume it is the default system one. +if [ -n "$(ynh_app_setting_get --app=$app --key=custom_error_file)" ]; then + custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) fi # Delete old user @@ -96,10 +96,9 @@ then fi # Add the config error code -if [ -n "$(ynh_app_setting_get --app=$app --key=codeerror)" ]; +if [ ! $custom_error_file ] then - echo add the error config - ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error.conf" + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" fi # Create a dedicated NGINX config From 9384644c80989f1a3dfc476c119d0b060902152d Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Wed, 16 Aug 2023 18:40:21 +0200 Subject: [PATCH 12/65] Update upgrade script to fix the unbound variable error --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index a9beb78..4becbd5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,7 +57,7 @@ if [ -z "$phpversion" ]; then fi # If custom_error_files doesn't exist, create it. We assume it is the default system one. -if [ -n "$(ynh_app_setting_get --app=$app --key=custom_error_file)" ]; then +if [ -z "$custom_error_file" ]; then custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) fi From 613e58e14929204295c1ca8ab9758de8734fd7e0 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Wed, 16 Aug 2023 18:49:45 +0200 Subject: [PATCH 13/65] Change a set value --- scripts/config | 3 ++- scripts/upgrade | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/config b/scripts/config index 319756e..1cbd2a5 100644 --- a/scripts/config +++ b/scripts/config @@ -148,9 +148,10 @@ ynh_app_config_apply() { ynh_system_user_del_group --username=$app --groups="sftp.app" fi - if [ "${changed[errorfile]}" == "true" ] + if [ "${changed[$custom_error_file]}" == "true" ] then echo Update error nginx config + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" fi if [ "$phpversion" != "none" ] diff --git a/scripts/upgrade b/scripts/upgrade index 4becbd5..a9beb78 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,7 +57,7 @@ if [ -z "$phpversion" ]; then fi # If custom_error_files doesn't exist, create it. We assume it is the default system one. -if [ -z "$custom_error_file" ]; then +if [ -n "$(ynh_app_setting_get --app=$app --key=custom_error_file)" ]; then custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) fi From c0688fc115b5cf13d9c5d79decfa8a210d17aeb9 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Wed, 16 Aug 2023 18:56:49 +0200 Subject: [PATCH 14/65] Add more debug info --- scripts/upgrade | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index a9beb78..51369cf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,10 +56,17 @@ if [ -z "$phpversion" ]; then ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion fi -# If custom_error_files doesn't exist, create it. We assume it is the default system one. +echo Init the custom error variable +# If custom_error_file doesn't exist, create it. We assume it is the default system one. if [ -n "$(ynh_app_setting_get --app=$app --key=custom_error_file)" ]; then + echo Variable not existing, create-it custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) +else + echo The variable exist fi +echo Test a condition +echo ynh_app_setting_get --app=$app --key=custom_error_file +echo Value return # Delete old user if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] @@ -95,6 +102,7 @@ then YNH_PHP_VERSION="$phpversion" fi +echo call this variable $custom_error_file # Add the config error code if [ ! $custom_error_file ] then From 33968949856a61ed8a99eb843e5a53904aed50e9 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Wed, 16 Aug 2023 19:29:01 +0200 Subject: [PATCH 15/65] Update config file --- scripts/config | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index 1cbd2a5..baf65b7 100644 --- a/scripts/config +++ b/scripts/config @@ -150,7 +150,7 @@ ynh_app_config_apply() { if [ "${changed[$custom_error_file]}" == "true" ] then - echo Update error nginx config + CUSTOM_ERROR_FILE=$custom_error_file ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" fi @@ -158,6 +158,11 @@ ynh_app_config_apply() { then ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint fi + + if [ ! $custom_error_file ] + then + ynh_app_setting_set --app=$app --key=custom_error_file --value="$custom_error_file" + fi } ynh_app_config_run $1 From 83394391359f4e49eb62a2d5f19f6e7e53977b13 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 11:05:13 +0200 Subject: [PATCH 16/65] Fix bad variable allocation --- scripts/upgrade | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 51369cf..b895c34 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,9 +56,8 @@ if [ -z "$phpversion" ]; then ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion fi -echo Init the custom error variable # If custom_error_file doesn't exist, create it. We assume it is the default system one. -if [ -n "$(ynh_app_setting_get --app=$app --key=custom_error_file)" ]; then +if [ -z "$custom_error_file" ]; then echo Variable not existing, create-it custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) else From 7b02f2817e88b0b99b76e74c111d15cf3326413d Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 11:25:18 +0200 Subject: [PATCH 17/65] Another test about the init variable --- scripts/upgrade | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index b895c34..6260a83 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,16 +56,12 @@ if [ -z "$phpversion" ]; then ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion fi +ynh_script_progression --message="Start to init custom error code" # If custom_error_file doesn't exist, create it. We assume it is the default system one. -if [ -z "$custom_error_file" ]; then - echo Variable not existing, create-it +if [ -z "${custom_error_file}" ]; then + ynh_script_progression --message="Variable not existing, create-it" custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) -else - echo The variable exist fi -echo Test a condition -echo ynh_app_setting_get --app=$app --key=custom_error_file -echo Value return # Delete old user if [ -n "$(ynh_app_setting_get --app=$app --key=user)" ] From f06a4f5ba9825f9855f76ee6e33a174973bfbc3d Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 11:33:48 +0200 Subject: [PATCH 18/65] Try another conditional test --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 6260a83..8f249d6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -58,7 +58,7 @@ fi ynh_script_progression --message="Start to init custom error code" # If custom_error_file doesn't exist, create it. We assume it is the default system one. -if [ -z "${custom_error_file}" ]; then +if [ -z "${custom_error_file:-}" ]; then ynh_script_progression --message="Variable not existing, create-it" custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) fi From ab804195664e8b96ae46bb164b799cf3b01a58b3 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 15:01:51 +0200 Subject: [PATCH 19/65] Write a short description info about the 404 errors setup --- doc/DESCRIPTION.md | 2 ++ doc/DESCRIPTION_fr.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index de48a9d..67b9aaf 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -5,3 +5,5 @@ It can also create a MySQL database - which will be backed up and restored with PHP-FPM version can also be selected among `none`, `7.4`, `8.0`, `8.1` and `8.2`. **Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside. + +The application can also lets you manage 404 errors - if you activate the option. Simply create an`error` folder in the `www` root directory. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 2bf7f20..9e6de17 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -5,3 +5,5 @@ Elle peut également créer une base de données MySQL - qui sera sauvegardée e La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1` et `8.2`. **Une fois installé, rendez-vous sur l'URL choisie pour connaître l'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP.** Le mot de passe est celui que vous avez choisi lors de l'installation. Sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur. + +L'application vous permet aussi de gérer - si vous activez l'option - la gestion des erreurs 404, il vous suffit de créer un dossier `error` dans le répertoire racine `www`. \ No newline at end of file From 92c86736468865fe08b50af0444ed932dc58f1be Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 15:49:08 +0200 Subject: [PATCH 20/65] Tweak the description en/fr --- doc/DESCRIPTION.md | 2 +- doc/DESCRIPTION_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 67b9aaf..55475c8 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -6,4 +6,4 @@ PHP-FPM version can also be selected among `none`, `7.4`, `8.0`, `8.1` and `8.2` **Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside. -The application can also lets you manage 404 errors - if you activate the option. Simply create an`error` folder in the `www` root directory. \ No newline at end of file +The application can also lets you manage 404 errors - if you activate the post-install option. Simply create an`error` folder in the `www` root directory. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 9e6de17..35ac7a6 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -6,4 +6,4 @@ La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1 **Une fois installé, rendez-vous sur l'URL choisie pour connaître l'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP.** Le mot de passe est celui que vous avez choisi lors de l'installation. Sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur. -L'application vous permet aussi de gérer - si vous activez l'option - la gestion des erreurs 404, il vous suffit de créer un dossier `error` dans le répertoire racine `www`. \ No newline at end of file +L'application vous permet aussi de gérer - si vous activez l'option en post-installe - la gestion des erreurs 404, il vous suffit de créer un dossier `error` dans le répertoire racine `www`. \ No newline at end of file From 1e5d23df24c50aad621e3c3f487264224ea4a95a Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 15:57:28 +0200 Subject: [PATCH 21/65] Update the update script --- scripts/upgrade | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/upgrade b/scripts/upgrade index 8f249d6..508b986 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -61,6 +61,7 @@ ynh_script_progression --message="Start to init custom error code" if [ -z "${custom_error_file:-}" ]; then ynh_script_progression --message="Variable not existing, create-it" custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) + ynh_app_setting_set --app=$app --key=custom_error_file --value=$custom_error_file fi # Delete old user From beb6c7e39976a8a04b7c1eb8b9301c922511f51d Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 16:20:51 +0200 Subject: [PATCH 22/65] Update nginx config Fix config function --- conf/nginx.conf | 3 ++- scripts/config | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index e522e75..5971601 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,7 +6,8 @@ location __PATH__/ { # Default indexes and catch-all index index.html index.php; - try_files $uri $uri/ __PATH__/index.php?$args =404; + # try_files $uri $uri/ __PATH__/index.php?$args =404; + try_files $uri $uri/ __PATH__/index.php?$args; # Prevent useless logs location = __PATH__/favicon.ico { diff --git a/scripts/config b/scripts/config index baf65b7..43d19bc 100644 --- a/scripts/config +++ b/scripts/config @@ -148,10 +148,13 @@ ynh_app_config_apply() { ynh_system_user_del_group --username=$app --groups="sftp.app" fi - if [ "${changed[$custom_error_file]}" == "true" ] + if [ "${changed[custom_error_file]}" == "true" ] then CUSTOM_ERROR_FILE=$custom_error_file ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + else + # TODO + echo remove config file fi if [ "$phpversion" != "none" ] From efc260135c332020581414b1be2c8b3aff129403 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 16:30:25 +0200 Subject: [PATCH 23/65] Variable not declared --- scripts/config | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/config b/scripts/config index 43d19bc..da5f3c0 100644 --- a/scripts/config +++ b/scripts/config @@ -151,6 +151,7 @@ ynh_app_config_apply() { if [ "${changed[custom_error_file]}" == "true" ] then CUSTOM_ERROR_FILE=$custom_error_file + nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" else # TODO From 632567c13fd6be4bb0a23fd2b6bcfb374d1789dc Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 16:33:34 +0200 Subject: [PATCH 24/65] Change path declaration --- scripts/config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/config b/scripts/config index da5f3c0..fb058e2 100644 --- a/scripts/config +++ b/scripts/config @@ -151,8 +151,7 @@ ynh_app_config_apply() { if [ "${changed[custom_error_file]}" == "true" ] then CUSTOM_ERROR_FILE=$custom_error_file - nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" - ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + ynh_add_config --template="nginx-code-error.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" else # TODO echo remove config file From d0255441315706ac5870d8a101b4f10b1605b9eb Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 17:01:36 +0200 Subject: [PATCH 25/65] On/Off nginx file --- scripts/config | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/config b/scripts/config index fb058e2..801c530 100644 --- a/scripts/config +++ b/scripts/config @@ -153,8 +153,7 @@ ynh_app_config_apply() { CUSTOM_ERROR_FILE=$custom_error_file ynh_add_config --template="nginx-code-error.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" else - # TODO - echo remove config file + ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" fi if [ "$phpversion" != "none" ] From e7b199e5737f937aa35df622a0271342761e9c7d Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 17:18:33 +0200 Subject: [PATCH 26/65] Remove old post-install info --- doc/POST_INSTALL_fr.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/doc/POST_INSTALL_fr.md b/doc/POST_INSTALL_fr.md index 3fda038..87467a7 100644 --- a/doc/POST_INSTALL_fr.md +++ b/doc/POST_INSTALL_fr.md @@ -5,10 +5,3 @@ Si vous avez demandé une base de données MYSQL, voici les informations de cett - Mot de passe : __DB_PWD__ La documentation ci-dessous contient également les informations pour se connecter en SSH et modifier le contenu du site web. - - - -Si vous avez activé la gestion du code d'erreur 404, vous pouvez placer un fichier 404.html, à la racine de votre -répertoire, le fichier sera alors reconnu par Nginx. - -Il est sinon possible de modifier le chemin dans l'administration afin de spécifier un repertoire. From d51c90ffb95693492d617bd7d7b7328654e8ba70 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 17:18:55 +0200 Subject: [PATCH 27/65] Remove unused setting set --- scripts/config | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/config b/scripts/config index 801c530..87d22b0 100644 --- a/scripts/config +++ b/scripts/config @@ -161,10 +161,6 @@ ynh_app_config_apply() { ynh_add_fpm_config --phpversion=$phpversion --usage=$fpm_usage --footprint=$fpm_footprint fi - if [ ! $custom_error_file ] - then - ynh_app_setting_set --app=$app --key=custom_error_file --value="$custom_error_file" - fi } ynh_app_config_run $1 From 42a5b8939372b2c98bee19e6196374f2e2ca9056 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 17:22:57 +0200 Subject: [PATCH 28/65] Test config script --- scripts/config | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index 87d22b0..42a5e9d 100644 --- a/scripts/config +++ b/scripts/config @@ -151,7 +151,8 @@ ynh_app_config_apply() { if [ "${changed[custom_error_file]}" == "true" ] then CUSTOM_ERROR_FILE=$custom_error_file - ynh_add_config --template="nginx-code-error.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" +# ynh_add_config --template="nginx-code-error.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" + ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" else ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" fi From 1b4c09bc1dbb64ca6e775937734b9bfdb90b8e7f Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 17:56:51 +0200 Subject: [PATCH 29/65] Update the On/Off error code parameter Revert nginx config --- conf/nginx.conf | 3 +-- scripts/config | 12 ++++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 5971601..e522e75 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -6,8 +6,7 @@ location __PATH__/ { # Default indexes and catch-all index index.html index.php; - # try_files $uri $uri/ __PATH__/index.php?$args =404; - try_files $uri $uri/ __PATH__/index.php?$args; + try_files $uri $uri/ __PATH__/index.php?$args =404; # Prevent useless logs location = __PATH__/favicon.ico { diff --git a/scripts/config b/scripts/config index 42a5e9d..d2b5e8c 100644 --- a/scripts/config +++ b/scripts/config @@ -151,10 +151,14 @@ ynh_app_config_apply() { if [ "${changed[custom_error_file]}" == "true" ] then CUSTOM_ERROR_FILE=$custom_error_file -# ynh_add_config --template="nginx-code-error.conf" --destination="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" - ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" - else - ynh_secure_remove --file="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" + nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" + + if [ "$custom_error_file" ] + then + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + else + ynh_secure_remove --file="$nginx_extra_conf_dir/error-code.conf" + fi fi if [ "$phpversion" != "none" ] From 9e6f1621b41de675962711acdd8fc08cb6615fb3 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 18:02:02 +0200 Subject: [PATCH 30/65] Clear the config panel file --- config_panel.toml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 48c03ed..812f02e 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -25,13 +25,7 @@ name = "My Webapp configuration" ask = "Activate the custom error file use" type = "boolean" default = false - help = "you enable this, you can create a custom `404.html` file at the root of your app to act as the custom 404 error page" - - # [main.code_error.path_folder] - # ask = "Specifie folder where your error file are sto" - # type = "string" - # default = "/" - # help = "You can set where your error file are store in your www folder." + help = "When you enable this, you can add/create a custom `404.html` file in a directory `www\\error`." [main.php_fpm_config] name = "PHP-FPM configuration" From 8c3b1e2161e62a7fb7362acc5430796bee87fc90 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 18:04:47 +0200 Subject: [PATCH 31/65] Update config with the conditional state in the custom error file section --- scripts/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index d2b5e8c..5fda374 100644 --- a/scripts/config +++ b/scripts/config @@ -153,7 +153,7 @@ ynh_app_config_apply() { CUSTOM_ERROR_FILE=$custom_error_file nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" - if [ "$custom_error_file" ] + if [ $custom_error_file ] then ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" else From 8d4188382b96a2a07307e443b47894822258c82a Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 18:08:11 +0200 Subject: [PATCH 32/65] Add debug info with the config file --- scripts/config | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/config b/scripts/config index 5fda374..a4ef631 100644 --- a/scripts/config +++ b/scripts/config @@ -152,11 +152,14 @@ ynh_app_config_apply() { then CUSTOM_ERROR_FILE=$custom_error_file nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" + ynh_print_info --message="Update the custom setting $custom_error_file" if [ $custom_error_file ] then + ynh_print_info --message="Add the config file" ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" else + ynh_print_info --message="Remove the config file" ynh_secure_remove --file="$nginx_extra_conf_dir/error-code.conf" fi fi From 18041281e30df674665c0c54e0855c8deac7446c Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 18:13:41 +0200 Subject: [PATCH 33/65] Update config with int comparaison --- scripts/config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/config b/scripts/config index a4ef631..4c8b5c9 100644 --- a/scripts/config +++ b/scripts/config @@ -154,11 +154,12 @@ ynh_app_config_apply() { nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" ynh_print_info --message="Update the custom setting $custom_error_file" - if [ $custom_error_file ] + if [ $custom_error_file -eq 1 ] then ynh_print_info --message="Add the config file" ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" - else + elif [ $custom_error_file -eq 0 ] + then ynh_print_info --message="Remove the config file" ynh_secure_remove --file="$nginx_extra_conf_dir/error-code.conf" fi From ea8278b48bdbdd8d75b5cafb8f03a604c7169580 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 18:19:59 +0200 Subject: [PATCH 34/65] Add the 403 error code build --- conf/nginx-code-error.conf | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index dba1050..bb32b79 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -1,4 +1,9 @@ # Build error access +error_page 403 /error/403.html; +location = __PATH__/error/403.html { + internal; +} + error_page 404 /error/404.html; location = __PATH__/error/404.html { internal; From 5f1dfbd192c9fac1d066817ad732c3605be25b2e Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 18:22:53 +0200 Subject: [PATCH 35/65] Wrong path construction with the nginx error code --- conf/nginx-code-error.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index bb32b79..4b71cff 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -1,10 +1,10 @@ # Build error access error_page 403 /error/403.html; -location = __PATH__/error/403.html { +location = /error/403.html { internal; } error_page 404 /error/404.html; -location = __PATH__/error/404.html { +location = /error/404.html { internal; } \ No newline at end of file From a561b9c449abb5315a17a56d5d977836c00e8987 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 19:10:47 +0200 Subject: [PATCH 36/65] Try another way with the status code return --- conf/nginx-code-error.conf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index 4b71cff..5807407 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -4,7 +4,8 @@ location = /error/403.html { internal; } -error_page 404 /error/404.html; -location = /error/404.html { - internal; -} \ No newline at end of file +error_page 404 @error404; + +location @error404 { + rewrite ^ /error/404.html last; +} From adf7f2ba838b07f1c076789eb5ab84c44da8010a Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 19:33:37 +0200 Subject: [PATCH 37/65] Change - once again - the nginx error build --- conf/nginx-code-error.conf | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index 5807407..c1e14cf 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -1,11 +1,8 @@ # Build error access error_page 403 /error/403.html; -location = /error/403.html { +error_page 404 /error/404.html; + +location ^/ /error* { internal; -} - -error_page 404 @error404; - -location @error404 { - rewrite ^ /error/404.html last; + root /var/www/my_webapp__3/www/; } From 08a58729a2febca4d84cf6d3c08051e55507cdfc Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Thu, 17 Aug 2023 19:33:37 +0200 Subject: [PATCH 38/65] Change - once again - the nginx error build --- conf/nginx-code-error.conf | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index 5807407..074b013 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -1,11 +1,8 @@ # Build error access error_page 403 /error/403.html; -location = /error/403.html { +error_page 404 /error/404.html; + +location ^/ /error/ { internal; -} - -error_page 404 @error404; - -location @error404 { - rewrite ^ /error/404.html last; + root /var/www/my_webapp__3/www/; } From 04338ac0911c07a4e4dde6372423b5ed3f28fd0b Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 09:19:41 +0200 Subject: [PATCH 39/65] Restart Nginx with the config update --- scripts/config | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/config b/scripts/config index 4c8b5c9..bc90b0d 100644 --- a/scripts/config +++ b/scripts/config @@ -163,6 +163,7 @@ ynh_app_config_apply() { ynh_print_info --message="Remove the config file" ynh_secure_remove --file="$nginx_extra_conf_dir/error-code.conf" fi + ynh_systemd_action --service_name=nginx --action=restart fi if [ "$phpversion" != "none" ] From c409b9d0e103c5f5a182955a6202e982aab5471b Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 09:40:42 +0200 Subject: [PATCH 40/65] Clear debug message, and add a restart about Nginx service --- scripts/config | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/config b/scripts/config index bc90b0d..278b74e 100644 --- a/scripts/config +++ b/scripts/config @@ -152,15 +152,12 @@ ynh_app_config_apply() { then CUSTOM_ERROR_FILE=$custom_error_file nginx_extra_conf_dir="/etc/nginx/conf.d/$domain.d/$app.d" - ynh_print_info --message="Update the custom setting $custom_error_file" if [ $custom_error_file -eq 1 ] then - ynh_print_info --message="Add the config file" ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" elif [ $custom_error_file -eq 0 ] then - ynh_print_info --message="Remove the config file" ynh_secure_remove --file="$nginx_extra_conf_dir/error-code.conf" fi ynh_systemd_action --service_name=nginx --action=restart From b578765b41ffd4c89113432d726b1fe97c6c24a8 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 09:55:41 +0200 Subject: [PATCH 41/65] Fix location path error config --- conf/nginx-code-error.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index 074b013..dad5740 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -2,7 +2,7 @@ error_page 403 /error/403.html; error_page 404 /error/404.html; -location ^/ /error/ { +location ^~ /error/ { internal; root /var/www/my_webapp__3/www/; } From db2876a58aae1f68ff6e16a5b90999130f0b4ddd Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 10:01:56 +0200 Subject: [PATCH 42/65] Remove unused setup --- conf/nginx-code-error.conf | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index dad5740..bebbabe 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -4,5 +4,4 @@ error_page 404 /error/404.html; location ^~ /error/ { internal; - root /var/www/my_webapp__3/www/; } From bcdf80162f646a633056d7d28cfd7840b522ae5d Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 10:12:23 +0200 Subject: [PATCH 43/65] Add information in the admin fr/en text --- doc/ADMIN.md | 4 ++++ doc/ADMIN_fr.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 6269999..5dc0377 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -19,6 +19,10 @@ Once logged in SFTP, under the Web directory, you will see a `www` folder which If you forgot your SFTP password, you can change it in YunoHost's webadmin interface in `Apps > My webapp > My Webapp configuration`. +### 403 and 404 error handling + +The web server configuration supports http error handling `403` and `404` (access denied and resource not found), just add an `error` folder in the `www` directory, then your `403.html` and `404.html` files. + ### Customizing the nginx configuration If you want to add tweak the nginx configuration for this app, it is recommended to edit `/etc/nginx/conf.d/__DOMAIN__.d/__ID__.d/WHATEVER_NAME.conf` (ensure that the file has the `.conf` extension) and reload the nginx after making sure that the configuration is valid using `nginx -t`. diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 562ba76..292e61d 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -23,6 +23,10 @@ Si vous avez oublié votre mot de passe SFTP, vous pouvez le changer dans la web Si vous n'arrivez pas à vous connecter et que vous avez vérifié que le nom d'utilisateur et le mot de passe sont bons, vérifiez si SFTP est activé pour votre app +### Gestion des erreurs 403 et 404 + +La configuration du serveur web prend en charge la gestion des erreurs http `403` et `404` (accès refusé et ressource non trouvé), il suffit de d'ajouter un dossier `error` dans le repertoire `www` puis vos fichiers `403.html` et `404.html`. + ### Personnaliser la configuration nginx Si vous souhaitez ajuster la configuration nginx pour cette app, il est recommandé d'éditer `/etc/nginx/conf.d/__DOMAIN__.d/__ID__.d/WHATEVER_NAME.conf` (assurez-vous que le fichier a l'extension `.conf`) puis rechargez nginx après vous être assuré que la configuration est valide à l'aide de `nginx -t`. From d7271b65afda416ce21810d090e6d897497e1142 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 10:19:31 +0200 Subject: [PATCH 44/65] Update the nginx to be reload and not restart --- scripts/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/config b/scripts/config index 278b74e..0958338 100644 --- a/scripts/config +++ b/scripts/config @@ -160,7 +160,7 @@ ynh_app_config_apply() { then ynh_secure_remove --file="$nginx_extra_conf_dir/error-code.conf" fi - ynh_systemd_action --service_name=nginx --action=restart + ynh_systemd_action --service_name=nginx --action=reload fi if [ "$phpversion" != "none" ] From 9d885a896aeb5695f27ffc7e0c9640b440a77e71 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 10:35:16 +0200 Subject: [PATCH 45/65] Set to true the default error code status used --- config_panel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_panel.toml b/config_panel.toml index 812f02e..cfc6f87 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -24,7 +24,7 @@ name = "My Webapp configuration" [main.code_error.custom_error_file] ask = "Activate the custom error file use" type = "boolean" - default = false + default = true help = "When you enable this, you can add/create a custom `404.html` file in a directory `www\\error`." [main.php_fpm_config] From 7b0b29cdccfbba44c1afb05f9e54acc553a42cac Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 10:46:04 +0200 Subject: [PATCH 46/65] Update install and upgrade script. Clear old debug info. --- scripts/install | 4 ++-- scripts/upgrade | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/scripts/install b/scripts/install index d671e86..f88e123 100644 --- a/scripts/install +++ b/scripts/install @@ -63,10 +63,10 @@ then YNH_PHP_VERSION="$phpversion" fi -if [ ! $custom_error_file ] +if [ $custom_error_file -eq 1 ] then ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" - CUSTOM_ERROR_FILE="$custom_error_file" + #CUSTOM_ERROR_FILE="$custom_error_file" fi # Create a dedicated NGINX config diff --git a/scripts/upgrade b/scripts/upgrade index 508b986..ac436ca 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -56,11 +56,9 @@ if [ -z "$phpversion" ]; then ynh_app_setting_set --app=$app --key=phpversion --value=$phpversion fi -ynh_script_progression --message="Start to init custom error code" -# If custom_error_file doesn't exist, create it. We assume it is the default system one. +# If custom_error_file doesn't exist, create it. if [ -z "${custom_error_file:-}" ]; then - ynh_script_progression --message="Variable not existing, create-it" - custom_error_file=$(ynh_app_setting_get --app=$app --key=custom_error_file) + custom_error_file=1 ynh_app_setting_set --app=$app --key=custom_error_file --value=$custom_error_file fi @@ -98,9 +96,8 @@ then YNH_PHP_VERSION="$phpversion" fi -echo call this variable $custom_error_file # Add the config error code -if [ ! $custom_error_file ] +if [ $custom_error_file -eq 1 ] then ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" fi From 791d7880e9a25ffe81d40db8a31a41dd3be03124 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 11:06:48 +0200 Subject: [PATCH 47/65] Fix the install script --- scripts/install | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index f88e123..2edeba2 100644 --- a/scripts/install +++ b/scripts/install @@ -63,12 +63,8 @@ then YNH_PHP_VERSION="$phpversion" fi -if [ $custom_error_file -eq 1 ] -then - ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" - #CUSTOM_ERROR_FILE="$custom_error_file" -fi - +# Add the custom error build with the application +ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" # Create a dedicated NGINX config ynh_add_nginx_config ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf" From 1eb8d54769d6c6a1cc63f7a20ea55b3e88ecf90d Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 11:10:25 +0200 Subject: [PATCH 48/65] init the custom error config --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 2edeba2..b98a257 100644 --- a/scripts/install +++ b/scripts/install @@ -65,6 +65,8 @@ fi # Add the custom error build with the application ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" +CUSTOM_ERROR_FILE=1 + # Create a dedicated NGINX config ynh_add_nginx_config ynh_add_config --template="example-custom-nginx-config.conf" --destination="$nginx_extra_conf_dir/sample.conf" From 7d919559a1564b8a790905b3b274b2badcf87129 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 11:19:17 +0200 Subject: [PATCH 49/65] Variable type set --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index b98a257..7375167 100644 --- a/scripts/install +++ b/scripts/install @@ -65,7 +65,7 @@ fi # Add the custom error build with the application ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" -CUSTOM_ERROR_FILE=1 +CUSTOM_ERROR_FILE="true" # Create a dedicated NGINX config ynh_add_nginx_config From 0f008b68d26a6b77066e8586f028264b35cb0c76 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 11:23:39 +0200 Subject: [PATCH 50/65] Fix setting set about custom error code value --- scripts/install | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 7375167..b3de321 100644 --- a/scripts/install +++ b/scripts/install @@ -65,7 +65,8 @@ fi # Add the custom error build with the application ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" -CUSTOM_ERROR_FILE="true" +ynh_app_setting_set --app=$app --key=custom_error_file --value="true" + # Create a dedicated NGINX config ynh_add_nginx_config From c4cc60d93fa4c931d9b01ee35d72abc324f1d465 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 14:29:42 +0200 Subject: [PATCH 51/65] Update location path, fix about the sub-dir setting --- conf/nginx-code-error.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index bebbabe..aa25131 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -2,6 +2,6 @@ error_page 403 /error/403.html; error_page 404 /error/404.html; -location ^~ /error/ { +location ^~ __PATH__/error/ { internal; } From 467aef4618d35cc6a860518d3a7b52666bbff7ba Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Fri, 18 Aug 2023 16:32:42 +0200 Subject: [PATCH 52/65] Update location path, fix about the sub-dir setting ; and change url --- conf/nginx-code-error.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx-code-error.conf b/conf/nginx-code-error.conf index aa25131..5ded6cc 100644 --- a/conf/nginx-code-error.conf +++ b/conf/nginx-code-error.conf @@ -1,6 +1,6 @@ # Build error access -error_page 403 /error/403.html; -error_page 404 /error/404.html; +error_page 403 __PATH__/error/403.html; +error_page 404 __PATH__/error/404.html; location ^~ __PATH__/error/ { internal; From ac625f32d3face1ec2e945e169607d7977355072 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 12:31:26 +0200 Subject: [PATCH 53/65] Change description info to be more accurate --- doc/DESCRIPTION.md | 2 +- doc/DESCRIPTION_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/DESCRIPTION.md b/doc/DESCRIPTION.md index 55475c8..69a0d76 100644 --- a/doc/DESCRIPTION.md +++ b/doc/DESCRIPTION.md @@ -6,4 +6,4 @@ PHP-FPM version can also be selected among `none`, `7.4`, `8.0`, `8.1` and `8.2` **Once installed, go to the chosen URL to know the user, domain and port you will have to use for the SFTP access.** The password is one you chosen during the installation. Under the Web directory, you will see a `www` folder which contains the public files served by this app. You can put all the files of your custom Web application inside. -The application can also lets you manage 404 errors - if you activate the post-install option. Simply create an`error` folder in the `www` root directory. \ No newline at end of file +You can also customize 404 errors - if you enable the option in the config panel. Simply create an`error` folder in the `www` root directory, containing your custom `html` files. \ No newline at end of file diff --git a/doc/DESCRIPTION_fr.md b/doc/DESCRIPTION_fr.md index 35ac7a6..a274e6f 100644 --- a/doc/DESCRIPTION_fr.md +++ b/doc/DESCRIPTION_fr.md @@ -6,4 +6,4 @@ La version de PHP-FPM peut aussi être choisie, parmi `none`, `7.4`, `8.0`, `8.1 **Une fois installé, rendez-vous sur l'URL choisie pour connaître l'utilisateur, le domaine et le port que vous devrez utiliser pour l'accès SFTP.** Le mot de passe est celui que vous avez choisi lors de l'installation. Sous le répertoire Web, vous verrez un dossier `www` qui contient les fichiers publics servis par cette application. Vous pouvez mettre tous les fichiers de votre application Web personnalisée à l'intérieur. -L'application vous permet aussi de gérer - si vous activez l'option en post-installe - la gestion des erreurs 404, il vous suffit de créer un dossier `error` dans le répertoire racine `www`. \ No newline at end of file +L'application vous permet aussi de gérer - si vous activez l'option dans le panneau de configuration - la gestion des erreurs 404, il vous suffit de créer un dossier `error` dans le répertoire racine `www` et d'y placer vos fichiers d'erreur `html` \ No newline at end of file From ad2673106c29fcba75ddb8e2dc8e8987282a29cf Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 13:27:43 +0200 Subject: [PATCH 54/65] Update change_url script to update location path nginx error --- scripts/change_url | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 4433872..a373e5a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -52,6 +52,12 @@ then domain="$old_domain" path_url="$new_path" + # Update custom error file path if needed + if [ $custom_error_file -eq 1 ] + then + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + fi + # Create a dedicated NGINX config ynh_add_nginx_config fi @@ -62,6 +68,7 @@ then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf" + ynh_delete_file_checksum --file="$nginx_extra_conf_dir/nginx-code-error.conf" path_url="$new_path" domain="$old_domain" @@ -74,6 +81,7 @@ then # Store file checksum for the new config file location ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/php.conf" + ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/nginx-code-error.conf" fi #================================================= From c4c9581eabb599b8e8830fb8a953d82aab9cc430 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 13:31:36 +0200 Subject: [PATCH 55/65] Generate backup about the custom error setup --- scripts/backup | 9 +++++++++ scripts/change_url | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 17b1472..4786b1d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -36,6 +36,15 @@ then ynh_backup --src_path="/etc/php/${phpversion}/fpm/pool.d/$app.conf" fi +#================================================= +# BACKUP CUSTOM CONF +#================================================= + +if [ $custom_error_file -eq 1 ] +then + ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d/nginx-code-error.conf" +fi + #================================================= # BACKUP THE MYSQL DATABASE #================================================= diff --git a/scripts/change_url b/scripts/change_url index a373e5a..1cc7ea7 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -58,7 +58,7 @@ then ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" fi - # Create a dedicated NGINX config + # Create a dedicated NGINX configssh ynh_add_nginx_config fi From ee658ef96663e3a6a18e3b8312cbeae531a72447 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 13:32:40 +0200 Subject: [PATCH 56/65] Comment change url config --- scripts/change_url | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 1cc7ea7..9018ece 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -53,10 +53,10 @@ then path_url="$new_path" # Update custom error file path if needed - if [ $custom_error_file -eq 1 ] - then - ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" - fi + #if [ $custom_error_file -eq 1 ] + #then + # ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + #fi # Create a dedicated NGINX configssh ynh_add_nginx_config @@ -68,7 +68,7 @@ then # Delete file checksum for the old conf file location ynh_delete_file_checksum --file="$nginx_conf_path" ynh_delete_file_checksum --file="$nginx_extra_conf_dir/php.conf" - ynh_delete_file_checksum --file="$nginx_extra_conf_dir/nginx-code-error.conf" + #ynh_delete_file_checksum --file="$nginx_extra_conf_dir/nginx-code-error.conf" path_url="$new_path" domain="$old_domain" @@ -81,7 +81,7 @@ then # Store file checksum for the new config file location ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/php.conf" - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/nginx-code-error.conf" + #ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.d/nginx-code-error.conf" fi #================================================= From 9dbb8b1821e2fde3e981862fd0f2cfb4613ab748 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 14:59:50 +0200 Subject: [PATCH 57/65] Fix warning message about the backup --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 4786b1d..16dcc06 100644 --- a/scripts/backup +++ b/scripts/backup @@ -40,7 +40,7 @@ fi # BACKUP CUSTOM CONF #================================================= -if [ $custom_error_file -eq 1 ] +if [ $custom_error_file == "true"] then ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d/nginx-code-error.conf" fi From 2c0b155c9447b1547cf5f8e4236982f3f8a12f29 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 15:02:29 +0200 Subject: [PATCH 58/65] Change conditional expression --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 16dcc06..d224333 100644 --- a/scripts/backup +++ b/scripts/backup @@ -40,7 +40,7 @@ fi # BACKUP CUSTOM CONF #================================================= -if [ $custom_error_file == "true"] +if [ $custom_error_file ] then ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d/nginx-code-error.conf" fi From 66626c71c79f718cd8e624ecd42240aae4e2922d Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 15:04:42 +0200 Subject: [PATCH 59/65] Wrong backup path --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index d224333..1f0c044 100644 --- a/scripts/backup +++ b/scripts/backup @@ -42,7 +42,7 @@ fi if [ $custom_error_file ] then - ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d/nginx-code-error.conf" + ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d/code-error.conf" fi #================================================= From b6a23c7bc5b1b2b99a414fe60d09d621ab093e68 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 15:12:24 +0200 Subject: [PATCH 60/65] Wrong filename --- scripts/backup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/backup b/scripts/backup index 1f0c044..3aafb41 100644 --- a/scripts/backup +++ b/scripts/backup @@ -42,7 +42,7 @@ fi if [ $custom_error_file ] then - ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d/code-error.conf" + ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.d/error-code.conf" fi #================================================= From 44f371dae613c57d0fcae28cf9cd800675debb0f Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 15:20:52 +0200 Subject: [PATCH 61/65] WIP: Update the custom config file --- scripts/change_url | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index 9018ece..af6bc80 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -44,6 +44,7 @@ nginx_extra_conf_dir=/etc/nginx/conf.d/$old_domain.d/$app.d # Change the path in the NGINX config file if [ $change_path -eq 1 ] +ynh_print_info --message="Change the path in the Nginx config file" then # Make a backup of the original NGINX config file if modified ynh_backup_if_checksum_is_different --file="$nginx_conf_path" @@ -53,10 +54,11 @@ then path_url="$new_path" # Update custom error file path if needed - #if [ $custom_error_file -eq 1 ] - #then - # ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" - #fi + if [ $custom_error_file -eq 1 ] + ynh_print_info --message="Change the custom error config file" + then + ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" + fi # Create a dedicated NGINX configssh ynh_add_nginx_config From c1c68f946379af99cff8d560af2888096cc7a14a Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 15:38:14 +0200 Subject: [PATCH 62/65] Fix warning info with the change url script --- scripts/change_url | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/change_url b/scripts/change_url index af6bc80..d6a18d1 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -54,7 +54,7 @@ then path_url="$new_path" # Update custom error file path if needed - if [ $custom_error_file -eq 1 ] + if [ $custom_error_file ] ynh_print_info --message="Change the custom error config file" then ynh_add_config --template="nginx-code-error.conf" --destination="$nginx_extra_conf_dir/error-code.conf" From 66249120ded202a122310a931f53026a0bbe0e29 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Mon, 21 Aug 2023 15:50:54 +0200 Subject: [PATCH 63/65] Revert the default value, set to false --- config_panel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_panel.toml b/config_panel.toml index cfc6f87..812f02e 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -24,7 +24,7 @@ name = "My Webapp configuration" [main.code_error.custom_error_file] ask = "Activate the custom error file use" type = "boolean" - default = true + default = false help = "When you enable this, you can add/create a custom `404.html` file in a directory `www\\error`." [main.php_fpm_config] From 060e15e3658831a6696d8e25a07a21c44b8462d8 Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Wed, 27 Sep 2023 23:27:41 +0200 Subject: [PATCH 64/65] Update config_panel.toml Tweak the help message Co-authored-by: eric_G <46165813+ericgaspar@users.noreply.github.com> --- config_panel.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config_panel.toml b/config_panel.toml index 812f02e..dfe5e24 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -25,7 +25,7 @@ name = "My Webapp configuration" ask = "Activate the custom error file use" type = "boolean" default = false - help = "When you enable this, you can add/create a custom `404.html` file in a directory `www\\error`." + help = "Once custom error enabled, you can add/create a custom `404.html` file in a directory `www\\error`." [main.php_fpm_config] name = "PHP-FPM configuration" From 55190b8272bf0d36e1b0ca90b372411a6429bc47 Mon Sep 17 00:00:00 2001 From: tituspijean Date: Sun, 8 Oct 2023 10:40:01 +0200 Subject: [PATCH 65/65] Improve error pages documentation --- doc/ADMIN.md | 2 +- doc/ADMIN_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/ADMIN.md b/doc/ADMIN.md index 5dc0377..dae1579 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -21,7 +21,7 @@ If you forgot your SFTP password, you can change it in YunoHost's webadmin inter ### 403 and 404 error handling -The web server configuration supports http error handling `403` and `404` (access denied and resource not found), just add an `error` folder in the `www` directory, then your `403.html` and `404.html` files. +The web server configuration supports http error handling `403` and `404` (access denied and resource not found). Create an `error` folder at `__INSTALL_DIR__/www/error`, and put your `403.html` and `404.html` files in there. ### Customizing the nginx configuration diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 292e61d..a334a3a 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -25,7 +25,7 @@ Si vous n'arrivez pas à vous connecter et que vous avez vérifié que le nom d' ### Gestion des erreurs 403 et 404 -La configuration du serveur web prend en charge la gestion des erreurs http `403` et `404` (accès refusé et ressource non trouvé), il suffit de d'ajouter un dossier `error` dans le repertoire `www` puis vos fichiers `403.html` et `404.html`. +La configuration du serveur web prend en charge la gestion des erreurs http `403` et `404` (accès refusé et ressource non trouvée). Ajoutez un dossier `error` à l'emplacement `__INSTALL_DIR__/www/error`, puis ajoutez-y vos fichiers `403.html` et `404.html`. ### Personnaliser la configuration nginx