Software: lighttpd 1.4.79 on Debian 13
This could be used on other distros with some modification.
Not sure what the service names for lighttpd are in your particular distro. Also, www-data is the group in debian that runs the lighttpd daemon, it might be different in your particular distro.
I want to be able to manage 302 or 301 redirects from my home directory rather than editing config files owned by root.
# visudo /etc/sudoers.d/www-data-restart-lighttpd
%www-data <machine-hostname> = (root) NOPASSWD: /usr/bin/systemctl restart lighttpd.service
%www-data <machine-hostname> = (root) NOPASSWD: /usr/bin/systemctl stop lighttpd.service
%www-data <machine-hostname> = (root) NOPASSWD: /usr/bin/systemctl start lighttpd.service
# usermod -a -G www-data <username>
root@who:/etc/lighttpd/conf-enabled# cat 01_<somefilename>.conf
$HTTP["host"] == "<hostname>" {
# by default the redirects will be 301
url.redirect-code = 302
include "/home/<username>/lighttpd/redirects.conf"
server.document-root = "/var/www/<custom-folder>"
}
username@who:~/lighttpd$ pwd
/home/username/lighttpd
username@who:~/lighttpd$ cat redirects.conf
# <hostname> redirects
# https://redmine.lighttpd.net/projects/lighttpd/wiki/Mod_redirect#Examples
# ./restart.sh
# ./check.sh <slug>
url.redirect = (
"^/slug1(/?)" => "https://example.com/slug1",
"^/slug2(/?)" => "https://example.com/slug2",
"^/slug3(/?)" => "https://example.com/slug3",
)
sudo chown <username>:www-data /home/<username>/lighttpd/redirects.conf
sudo chmod o= /home/<username>/lighttpd/redirects.conf
./restart.sh
./check.sh slug-name
Create a simple script that takes over for user's default shell so that after ssh-ing into a machine the user is presented with prompts to update, restart, and check the redirects automatically. SaaS via SSH maybe...