1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/baikal_ynh.git synced 2024-09-03 18:16:11 +02:00

handle ".well-known" if it is already served on the domain (same way as Nextcloud)

This commit is contained in:
Gofannon 2018-05-01 23:23:42 +02:00
parent a53b1723a7
commit 244e67336c
3 changed files with 42 additions and 1 deletions

View file

@ -1,5 +1,18 @@
#!/bin/bash
#=================================================
# COMMON HELPERS -- SHOULD BE ADDED TO YUNOHOST
#=================================================
# Check if an URL is already handled
# usage: is_url_handled URL
is_url_handled() {
local output=($(curl -k -s -o /dev/null \
-w 'x%{redirect_url} %{http_code}' "$1"))
# It's handled if it does not redirect to the SSO nor return 404
[[ ! ${output[0]} =~ \/yunohost\/sso\/ && ${output[1]} != 404 ]]
}
# ============= FUTURE YUNOHOST HELPER =============
# Delete a file checksum from the app settings
#

View file

@ -70,6 +70,20 @@ ynh_setup_source "$final_path"
# NGINX CONFIGURATION
#=================================================
# Do not serve .well-known if it's already served on the domain
if https://github.com/YunoHost-Apps/nextcloud_ynh/blob/962cc61ec8ffb045d89dd460cf8b55778d862ffc/scripts/install "https://${domain}/.well-known/caldav" ; then
sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \
"../conf/nginx.conf"
fi
# Taken from https://github.com/YunoHost-Apps/nextcloud_ynh/blob/962cc61ec8ffb045d89dd460cf8b55778d862ffc/scripts/install
# Commented for now
#
# Handle root path, avoid double slash.
# Temporary fix, in waiting for an upgrade of the helper. (#361)
#path_url_slash_less=${path_url%/}
#ynh_replace_string "__PATH__/" "$path_url_slash_less/" "../conf/nginx.conf"
# Create a dedicated nginx config
ynh_add_nginx_config

View file

@ -64,6 +64,20 @@ ynh_setup_source "$final_path"
# NGINX CONFIGURATION
#=================================================
# Delete current nginx configuration to be able to check if .well-known is already served.
ynh_remove_nginx_config
ynh_app_setting_delete $app "checksum__etc_nginx_conf.d_$domain.d_$app.conf" || true
# Do not serve .well-known if it's already served on the domain
if is_url_handled "https://${domain}/.well-known/caldav" ; then
sed -ri '/^location = \/\.well\-known\/(caldav|carddav) \{/,/\}/d' \
"../conf/nginx.conf"
fi
# Handle root path, avoid double slash.
# Temporary fix, in waiting for an upgrade of the helper. (#361)
#path_url_slash_less=${path_url%/}
#ynh_replace_string "__PATH__/" "$path_url_slash_less/" "../conf/nginx.conf"
# Create a dedicated nginx config
ynh_add_nginx_config