diff options
author | Andrew Cady <d@jerkface.net> | 2023-06-01 18:11:20 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2023-06-01 18:11:20 -0400 |
commit | cc171c3917d410d4ca95bf305a9f247378fdbb2f (patch) | |
tree | 8a0c9ec63e40de9072a3a70edfd40e838fda8c3d | |
parent | 513765b244d5de1f54edbf4ba6be79c5933cfa3f (diff) |
automatic apache configuration of fossil reverse proxy for virtual host of local hostname
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | src/fossil-disable-apache@.service | 9 | ||||
-rw-r--r-- | src/fossil-enable-apache@.service | 14 | ||||
-rw-r--r-- | src/fossil.conf~template | 10 | ||||
-rw-r--r-- | src/user/fossil-httpd@.service | 2 |
5 files changed, 36 insertions, 2 deletions
@@ -1,4 +1,4 @@ | |||
1 | systemctl_start_units = fossil-user.socket | 1 | systemctl_start_units = fossil-user.socket fossil-enable-apache@-.service |
2 | systemctl_user_start_units = fossil-httpd.socket | 2 | systemctl_user_start_units = fossil-httpd.socket |
3 | 3 | ||
4 | ifneq (0,$(shell id -u)) | 4 | ifneq (0,$(shell id -u)) |
@@ -56,6 +56,7 @@ SSH_USERNAME != if [ "$$SUDO_USER" ]; then echo "$$SUDO_USER"; else id -u; fi | |||
56 | default: install start follow | 56 | default: install start follow |
57 | install: | 57 | install: |
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] | ||
2 | Description = Disable and clean up apache site | ||
3 | |||
4 | [Service] | ||
5 | Type = oneshot | ||
6 | ExecStart = sh -xc 'rm -f \ | ||
7 | /etc/apache2/sites-available/fossil-%H.conf \ | ||
8 | /etc/apache2/sites-enabled/fossil-%H.conf' | ||
9 | ExecStart = 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] | ||
2 | Description = Create and enable apache2 site | ||
3 | ConditionPathExists = /etc/apache2/sites-available/fossil.conf~template | ||
4 | ConditionPathExists = !/etc/apache2/sites-available/fossil-%H.conf | ||
5 | |||
6 | [Service] | ||
7 | Type = oneshot | ||
8 | ExecStart = sh -c '\ | ||
9 | sed -e s/%[H]/%H/ \ | ||
10 | < /etc/apache2/sites-available/fossil.conf~template \ | ||
11 | > /etc/apache2/sites-available/fossil-%H.conf \ | ||
12 | ' | ||
13 | ExecStart = a2ensite fossil-%H | ||
14 | ExecStart = 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] |
6 | StandardInput = socket | 6 | StandardInput = socket |
7 | ExecStart = fossil http --repolist --nossl --host=localhost:8079 --localauth ${HOME}/src/ | 7 | ExecStart = fossil http --repolist --nossl --host=%H --localauth ${HOME}/src/ |