Alright.
/etc/nginx# grep -r '/usr/share/yunohost/applogos/;' *
conf.d/yunohost_admin.conf.inc: alias /usr/share/yunohost/applogos/;
conf.d/yunohost_sso.conf.inc: alias /usr/share/yunohost/applogos/;
Le soucis là c’est que les requêtes envoyées à nginx sont mal routées, il essaye d’aller dans
/usr/share/nginx/html/yunohost/sso/qui n’a pas de sens …
En effet, ne pas oublier la verrue que j’ai du pondre un peu plus haut pour récupérer l’accès :
J’ai récupéré le SSO en créant le folder
/usr/share/nginx/html/yunohost/sso/et en copiant dedans le contenu du folder/usr/share/yunohost/portal
Et, clairement, j’ai aggravé le soucis en faisant la copie de ce folder.
En le supprimant ainsi que mon hook, j’ai un fonctionnement normal.
Contenu du hook ( basé sur Tuto: Bloquer les requêtes selon le pays ) :
#!/bin/bash
# A placer dans /etc/yunohost/hooks.d/conf_regen/
# Voir https://forum.yunohost.org/t/tuto-bloquer-les-requetes-selon-le-pays/9947
# if not present, add package geoip-database with apt install geoip-database
##############################################
#Beware, i'm not sure this command is universal. You must test it before. If not, you can find the result with the command ip route, this one must be like 192.168.0.0/24 or similar. Then replace the variable $network_address with it.
#Attention, je ne suis pas certain que cette commande est universelle. Vous devez la tester au préalable. Si ce n'est pas le cas, vous pouvez trouver la réponse avec la commande ip route, celle-ci doit être de la forme 192.168.0.0/24 ou similaire. Remplacez alors la var>network_address=$(awk '{print $1}' <(grep src <(ip route)))
################################################
action=$1
pending_dir=$4
nginx_dir=$pending_dir/../nginx/etc/nginx
nginx_security_conf=$nginx_dir/conf.d/security.conf.inc
nginx_country_conf=$nginx_dir/conf.d/country.conf
[[ $action == "pre" ]] || exit 0
[[ -d $nginx_dir ]] || exit 0
[[ -e $nginx_security_conf ]] || exit 0
#Now we create the Nginx country conf file
echo "# GeoIP databases
geoip_country /usr/share/GeoIP/GeoIP.dat;
map \$geoip_country_code \$allowed_country {
default no;
# France
FR yes;
CH yes;
# Italie
#IT yes;
}
geo \$lan-ip {
default no;
$network_address yes;
127.0.0.1 yes;
}" > $nginx_country_conf
#Next ,we modify Nginx security.conf.inc file
echo '
# allow local ip
if ($lan-ip = yes) {
set $allowed_country yes;
}
# block the country
#if ($allowed_country = no) {
# return 444;
#}
#blocage sur certaines url uniquement
location ~* /(sso) {
if ($allowed_country = no) {
return 444;
}
}
' >> $nginx_security_conf
#And then, we create the cron job.
echo "#!/bin/bash
maj_geoip () {
cd /usr/share/GeoIP
if grep 'inet6 [23]' <(ip -6 addr);then #test if the server can be join with ipv4+ipv6 or only ipv4
wget https://dl.miyuru.lk/geoip/maxmind/country/maxmind.dat.gz -O GeoIP.dat.gz #Download IPv4+IPv6 database
else
wget https://mailfud.org/geoip-legacy/GeoIP.dat.gz #Download IPv4 database
fi
gunzip -f GeoIP.dat.gz #unzip database
}}
last=/usr/local/etc/last #it is a file to write the last date update. It is use to compare if there is a new update when the cron job is execute. If not, there's nothing to do.
if grep 'inet6 [23]' <(ip -6 addr);then
update=\$(sed -n 's,.*<li>Maxmind : \(.*\)</li>,\1,p' <(curl -s https://www.miyuru.lk/geoiplegacy | grep 'Maxmind : ')) #Retrieve the last update of database ipv4+ipv6 date on miuru.lk
else
update=\$(sed -n 's,.*<b>\(.*\)</b>,\1,p' <(curl -s https://mailfud.org/geoip-legacy/ | grep 'Latest update')) #retrieve the last update date on mailfud.org
fi
[[ \"\$(<\$last)\" != \"\$update\" ]] && (echo \"\$update\" > \"\$last\";maj_geoip) #Test if there is an update. If yes, write the date in /usr/local/etc/last and execute the function maj_geoip.
exit 0" > /etc/cron.weekly/Geoipupdate
chmod 500 /etc/cron.weekly/Geoipupdate # give execution right to the cron job.
##############################################################
Sans surprise, la partie qui pose soucis est celle du blocage (si commentée, comportement normale du serveur) :
#blocage sur certaines url uniquement
location ~* /(sso) {
if ($allowed_country = no) {
return 444;
}
}
=> Je pense que la variable $nginx_dir n’est plus bonne avec le rework du sso.
Edit : Invocation de @metyun