Persistent configuration change with regen-conf hook

Yes, find is recursive. […] Whenever you modify a yunohost file, you can’t modify it directly but you must go through $nginx_dir.

Sorry, metyun, for not grasping right away that you where referring to the direct change in /etc/nginx/

In the end I settled for

#!/bin/bash

action=$1
pending_dir=$4
nginx_dir=$pending_dir/../nginx/etc/nginx
nginx_conf_dir=$nginx_dir/conf.d
[[ $action == "pre" ]] || exit 0
[[ -d $pending_dir ]] || exit 0
[[ -d $nginx_dir ]] || exit 0
nginx_webpage_conf=$(find "$nginx_conf_dir" -name website.com.conf)
[[ -e $nginx_webpage_conf ]] || exit 0
sed -i '/^server\s*{/,/^}/ { /^}/i\
\
    # nginx block xmlrpc.php requests\
    location /xmlrpc.php {\
        deny all;\
        return 403;\
    }
}' $nginx_webpage_conf

Interestingly, yunohost’s default wordpress nginx configuration in /etc/nginx/conf.d/website.com.d/wordpress.conf already foresees the blocking of the xmlrpc.php, however these rules for some reason do not appear to be applied, see this post.