From da32e51fd90019e8b3370256711774385be69bee Mon Sep 17 00:00:00 2001 From: selfhoster1312 Date: Sat, 24 Aug 2024 22:58:21 +0200 Subject: [PATCH] Start rewriting with jinja templates --- conf/nginx.conf | 35 ++++++++++++++++++++++++----------- manifest.toml | 1 + scripts/install | 2 +- tests.toml | 15 ++++++++++++--- 4 files changed, 38 insertions(+), 15 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index efeb0e3..25dbf8e 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,5 @@ -location @__NAME__--proxy { - proxy_pass __PROXY_PATH__; +location @{{ name }}--proxy { + proxy_pass {{ proxy_path }}; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -15,13 +15,26 @@ location @__NAME__--proxy { more_clear_input_headers 'Accept-Encoding'; } -# Support relative URLs -__REDIRECT_BLOCK__ - -location __PATH_SLASH__ { - # Include SSOWAT user panel. - include conf.d/yunohost_panel.conf.inc; - - __ASSETS_ALIAS__ - __TRY_FILES__ +location = {{ path }} { + return 302 {{ path }}; +} + +location {{ path }}/ { +{% if assets_path %} + alias {{ assets_path }}; +{% endif %} + + # This is a reverse-proxy, not a basic HTML site + # We do not wish to enable autoindex in general, and will + # not try_files uri/ for this reason. + # + # But if no assets_path is defined, try the backend directly. + # + # Note: We could include an app setting for autoindex some time. + # But try_files uri/ without autoindex will result in 403. +{% if assets_path %} + try_files $uri @{{ name }}--proxy =@404; +{% else %} + try_files ${{ name }}--proxy =@404; +{% endif %} } diff --git a/manifest.toml b/manifest.toml index 740c996..b674aff 100644 --- a/manifest.toml +++ b/manifest.toml @@ -14,6 +14,7 @@ license = "AGPL-3.0-or-later" website = "https://en.wikipedia.org/wiki/Reverse_proxy" [integration] +helpers_version = "2.1" yunohost = ">= 11.2" architectures = "all" multi_instance = true diff --git a/scripts/install b/scripts/install index 6b28dd2..83d09c4 100644 --- a/scripts/install +++ b/scripts/install @@ -25,7 +25,7 @@ rp_handle_webroot # Configure nginx ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -ynh_add_nginx_config +ynh_config_add --jinja --template = "nginx.conf" --destination="/etc/nginx.conf.d/${domain}.d/${app}.conf" #================================================= # END OF SCRIPT diff --git a/tests.toml b/tests.toml index ec288a8..ccbe1f1 100644 --- a/tests.toml +++ b/tests.toml @@ -1,7 +1,16 @@ test_format = 1.0 [default] - - + args.path = "/" args.proxy_path="http://127.0.0.1:6787" - args.assets_path="/usr/share/yunohost/admin" \ No newline at end of file + args.assets_path="/usr/share/yunohost/admin" + +[default.curl_tests] + # If needed, we can add a preinstall step, as shown here: + # https://github.com/YunoHost/package_check + + #admin.path = "/" + admin.expect_title = "YunoHost Admin" + + admin_css.path = "/assets/UserCreate-18b2103e.css" + admin_css.expect_content = ".custom-select[data-v-0d75331f]{flex-basis:40%}"