What type of hardware are you using: Old laptop or computer What YunoHost version are you running: 12.1.39 How are you able to access your server: SSH
Describe your issue
I intend to make persistent changes to a nginx configuration file in /etc/nginx/conf.d/website.com.conf. To this end I consulted the documentation of the hook system and made out two candidates: (1) conf-regen and (2) post_app_upgrade hooks. I settled for the former for no good reason and wrote the following script:
which I placed int /etc/yunohost/hooks.d/conf_regen/80-nginx_xlmrpc. However, the file is now marked as manually modified:
yunohost tools regen-conf throws the following error
Warning: The configuration file ‘/etc/nginx/conf.d/website.com.conf’ has been manually modified and will not be updated
After running yunohost tools regen-conf --force modifications are no longer present, yunohost tools regen-conf has to be run a second time, while modifications were written, the same warning was given again:
Warning: The configuration file ‘/etc/nginx/conf.d/website.com.conf’ has been manually modified and will not be updated
How would you put the hook in place to guarantee re-addition of my modifications to the configuration file in question? Thank you in advance for your suggestions.
It does not really matter, as find locates the unique file correctly, but yes it is in the sub-directory conf.d
Before you add the hook in /etc/yunohost/hooks.d/conf_regen/ , you must restore the default configuration with
I tried this (1 moving my hook, 2 executing regex-conf nginx --force, 3 executing regex-conf nginx --force), however, when executing the yunohost tools regen-conf nginx with the --force flag the second time, nothing happens an my hook does not get triggered, i.e. changes are not written to the file. Executing yunohost tools regen-conf nginx without the --force flag writes the changes but additionally generates the warning regarding file modification.
Any hook (the broad concept) or the this script used with the regen-conf hook? Regarding the latter, I have a Wordpress site running, and wanted to block access to the xmlrpc.php file. However, now I find that /etc/nginx/conf.d/website.com.d/wordpress.conf does already contain the following which however has no effect
You modify /etc/nginx/conf.d/website.com.conf directly without going through $nginx_dir
Whenever you modify a yunohost file, you can’t modify it directly but you must go through $nginx_dir. It’s why the regen-conf gives a warning and the --force don’t erase the default configuration.
For example, i use this in a hook :
Thank you, JfmbLinux, for your more general suggestion! Indeed, this could be beneficial. I will have to ensure that none of my installed apps requires direct exposure of php files before putting this into place and read more about Nginx’s directory structure.
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.