1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/nextcloud_ynh.git synced 2024-09-03 19:55:57 +02:00

[fix] Improve how .well-known path is checked

This commit is contained in:
Jérôme Lebleu 2016-07-18 21:47:30 +02:00
parent a6212bd4b0
commit cc21dc5fa3
3 changed files with 15 additions and 10 deletions

View file

@ -71,3 +71,12 @@ exec_occ() {
(cd "$WORKDIR" && exec_as "$AS_USER" \
php occ --no-interaction --no-ansi "$@")
}
# 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 ]]
}

View file

@ -70,12 +70,10 @@ sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf
# check if .well-known is already served on the domain
if [[ $(curl -s -o /dev/null -w '%{http_code}' \
"https://${domain}/.well-known/caldav") =~ ^[23] ]] ; then
# ... and delete it from nginx configuration
# 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
../conf/nginx.conf
fi
sudo cp ../conf/nginx.conf "$nginx_conf"

View file

@ -91,12 +91,10 @@ sed -i "s@#APP#@${app}@g" ../conf/nginx.conf
sed -i "s@#PATH#@${path}@g" ../conf/nginx.conf
sed -i "s@#LOCATION#@${path:-/}@g" ../conf/nginx.conf
sed -i "s@#DESTDIR#@${DESTDIR}@g" ../conf/nginx.conf
# check if .well-known is already served on the domain
if [[ $(curl -s -o /dev/null -w '%{http_code}' \
"https://${domain}/.well-known/caldav") =~ ^[23] ]] ; then
# ... and delete it from nginx configuration
# 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
../conf/nginx.conf
fi
sudo cp ../conf/nginx.conf "$nginx_conf"