summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cady <d@jerkface.net>2023-06-01 18:11:20 -0400
committerAndrew Cady <d@jerkface.net>2023-06-01 18:11:20 -0400
commitcc171c3917d410d4ca95bf305a9f247378fdbb2f (patch)
tree8a0c9ec63e40de9072a3a70edfd40e838fda8c3d
parent513765b244d5de1f54edbf4ba6be79c5933cfa3f (diff)
automatic apache configuration of fossil reverse proxy for virtual host of local hostname
-rw-r--r--Makefile3
-rw-r--r--src/fossil-disable-apache@.service9
-rw-r--r--src/fossil-enable-apache@.service14
-rw-r--r--src/fossil.conf~template10
-rw-r--r--src/user/fossil-httpd@.service2
5 files changed, 36 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index da5a2bf..def9421 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
1systemctl_start_units = fossil-user.socket 1systemctl_start_units = fossil-user.socket fossil-enable-apache@-.service
2systemctl_user_start_units = fossil-httpd.socket 2systemctl_user_start_units = fossil-httpd.socket
3 3
4ifneq (0,$(shell id -u)) 4ifneq (0,$(shell id -u))
@@ -56,6 +56,7 @@ SSH_USERNAME != if [ "$$SUDO_USER" ]; then echo "$$SUDO_USER"; else id -u; fi
56default: install start follow 56default: install start follow
57install: 57install:
58 install -t "$(bindir)" -- $(executables) 58 install -t "$(bindir)" -- $(executables)
59 install -m644 -t /etc/apache2/sites-available -- src/fossil.conf~template
59 install -t /etc/ssh/ -- src/AuthorizedKeysCommand 60 install -t /etc/ssh/ -- src/AuthorizedKeysCommand
60 install -T -- src/AnonymousForceCommand /etc/ssh/user-"$(SSH_USERNAME)".AnonymousForceCommand 61 install -T -- src/AnonymousForceCommand /etc/ssh/user-"$(SSH_USERNAME)".AnonymousForceCommand
61 install -m644 -t /etc/ssh/sshd_config.d -- src/fossil-user.conf 62 install -m644 -t /etc/ssh/sshd_config.d -- src/fossil-user.conf
diff --git a/src/fossil-disable-apache@.service b/src/fossil-disable-apache@.service
new file mode 100644
index 0000000..4d763e0
--- /dev/null
+++ b/src/fossil-disable-apache@.service
@@ -0,0 +1,9 @@
1[Unit]
2Description = Disable and clean up apache site
3
4[Service]
5Type = oneshot
6ExecStart = sh -xc 'rm -f \
7/etc/apache2/sites-available/fossil-%H.conf \
8/etc/apache2/sites-enabled/fossil-%H.conf'
9ExecStart = systemctl reload apache2
diff --git a/src/fossil-enable-apache@.service b/src/fossil-enable-apache@.service
new file mode 100644
index 0000000..d90a36f
--- /dev/null
+++ b/src/fossil-enable-apache@.service
@@ -0,0 +1,14 @@
1[Unit]
2Description = Create and enable apache2 site
3ConditionPathExists = /etc/apache2/sites-available/fossil.conf~template
4ConditionPathExists = !/etc/apache2/sites-available/fossil-%H.conf
5
6[Service]
7Type = oneshot
8ExecStart = sh -c '\
9sed -e s/%[H]/%H/ \
10< /etc/apache2/sites-available/fossil.conf~template \
11> /etc/apache2/sites-available/fossil-%H.conf \
12'
13ExecStart = a2ensite fossil-%H
14ExecStart = systemctl reload apache2
diff --git a/src/fossil.conf~template b/src/fossil.conf~template
new file mode 100644
index 0000000..797f5e2
--- /dev/null
+++ b/src/fossil.conf~template
@@ -0,0 +1,10 @@
1<VirtualHost *:80>
2 ServerName %H
3 ServerAdmin webmaster@%H
4 ErrorLog ${APACHE_LOG_DIR}/error.log
5 CustomLog ${APACHE_LOG_DIR}/access.log combined
6 DocumentRoot /var/www/html
7 ProxyPreserveHost on
8 ProxyPass / http://localhost:8079/
9 ProxyPassReverse / http://localhost:8079/
10</VirtualHost>
diff --git a/src/user/fossil-httpd@.service b/src/user/fossil-httpd@.service
index eccc17c..9c4aec5 100644
--- a/src/user/fossil-httpd@.service
+++ b/src/user/fossil-httpd@.service
@@ -4,4 +4,4 @@ ConditionUser = !root
4 4
5[Service] 5[Service]
6StandardInput = socket 6StandardInput = socket
7ExecStart = fossil http --repolist --nossl --host=localhost:8079 --localauth ${HOME}/src/ 7ExecStart = fossil http --repolist --nossl --host=%H --localauth ${HOME}/src/