Yunohost panel in parent location block, assets/try_files defined from bash

This commit is contained in:
selfhoster1312 2023-01-10 19:03:08 +01:00
parent d6838b36d3
commit a47af1ed63
2 changed files with 19 additions and 12 deletions

View file

@ -12,8 +12,6 @@ location @__NAME__--proxy {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
more_clear_input_headers 'Accept-Encoding';
}
@ -21,6 +19,9 @@ location @__NAME__--proxy {
__REDIRECT_BLOCK__
location __PATH_URL_SLASH__ {
alias __ASSETS_PATH__;
try_files $uri @__NAME__--proxy;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
__ASSETS_ALIAS__
__TRY_FILES__
}

View file

@ -26,9 +26,12 @@ rp_validate_proxy_path() {
# Verify that the requested assets path is valid
# - is a local folder
# - ends with a /
# Sets the alias line for serving static files,
# and the try_files line for trying those static files first
rp_validate_assets_path() {
if [[ "$assets_path" = "" ]]; then
assets_path="/dev/null"
assets_alias="# No static files to serve"
try_files="try_files /dev/null @${app}--proxy;"
else
if [ ! -d "$assets_path" ]; then
ynh_die "Requested assets path "$assets_path" does not exist" 1
@ -38,17 +41,20 @@ rp_validate_assets_path() {
# Append missing trailing /
assets_path=""${assets_path}"/"
fi
assets_alias="alias $assets_path;"
try_files="try_files \$uri \$uri/ @${app}--proxy;"
fi
}
# When the app is not in the webroot (path_url = /), need to add a redirect block
# to app/ so relative URLs work
rp_handle_webroot() {
if [[ "$path_url" = "/" ]]; then
path_url_slash="/"
redirect_block="# Not needed for webroot"
else
path_url_slash=""$path_url"/"
redirect_block="location = "$path_url" { return 302 "$path_url_slash"; }"
fi
if [[ "$path_url" = "/" ]]; then
path_url_slash="/"
redirect_block="# Not needed for webroot"
else
path_url_slash=""$path_url"/"
redirect_block="location = "$path_url" { return 302 "$path_url_slash"; }"
fi
}