I'll preface this by saying this post is just for me, it's for Alpine Linux and specific to one use case where I need a static file webserver but want to reconfigure the domains occasionally.
You can set up self-reloading config if you have a script that watches for file changes to the conf files. Just apk add inotify-tools and then create a script like this in /etc/inotify/nginx-reload.sh and make it chmod u+x nginx-reload.sh:-
#!/bin/bash set -e while true; do while inotifywait /var/www -e modify --include '.*\.conf'; do nginx -s reload done done
You then need to set this up to run on startup using openrc. Put the following in /etc/init.d/nginxreload and again, chmod it u+x:-
#!/sbin/openrc-run name="Nginx Reloader" command="/etc/inotify/nginx-reload.sh" command_args="" command_user="root" command_background=true pidfile="/etc/inotify/nginx-reload.pid" depend() { need net localmount }
Now run:-
rc-update add nginxreload default service nginxreload start
And any edits to the conf files specified result in nginx reloading its configuration.
Permalink