Start rewriting with jinja templates

This commit is contained in:
selfhoster1312 2024-08-24 22:58:21 +02:00
parent 3e1850d789
commit da32e51fd9
4 changed files with 38 additions and 15 deletions

View file

@ -1,5 +1,5 @@
location @__NAME__--proxy { location @{{ name }}--proxy {
proxy_pass __PROXY_PATH__; proxy_pass {{ proxy_path }};
proxy_redirect off; proxy_redirect off;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
@ -15,13 +15,26 @@ location @__NAME__--proxy {
more_clear_input_headers 'Accept-Encoding'; more_clear_input_headers 'Accept-Encoding';
} }
# Support relative URLs location = {{ path }} {
__REDIRECT_BLOCK__ return 302 {{ path }};
}
location __PATH_SLASH__ {
# Include SSOWAT user panel. location {{ path }}/ {
include conf.d/yunohost_panel.conf.inc; {% if assets_path %}
alias {{ assets_path }};
__ASSETS_ALIAS__ {% endif %}
__TRY_FILES__
# 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 %}
} }

View file

@ -14,6 +14,7 @@ license = "AGPL-3.0-or-later"
website = "https://en.wikipedia.org/wiki/Reverse_proxy" website = "https://en.wikipedia.org/wiki/Reverse_proxy"
[integration] [integration]
helpers_version = "2.1"
yunohost = ">= 11.2" yunohost = ">= 11.2"
architectures = "all" architectures = "all"
multi_instance = true multi_instance = true

View file

@ -25,7 +25,7 @@ rp_handle_webroot
# Configure nginx # Configure nginx
ynh_script_progression --message="Configuring NGINX web server..." --weight=1 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 # END OF SCRIPT

View file

@ -1,7 +1,16 @@
test_format = 1.0 test_format = 1.0
[default] [default]
args.path = "/"
args.proxy_path="http://127.0.0.1:6787" args.proxy_path="http://127.0.0.1:6787"
args.assets_path="/usr/share/yunohost/admin" 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%}"