diff options
| author | Sebastian Korotkiewicz <skorotkiewicz@gmail.com> | 2026-08-10 02:31:34 +0200 |
|---|---|---|
| committer | Sebastian Korotkiewicz <skorotkiewicz@gmail.com> | 2026-08-10 02:31:34 +0200 |
| signature | Sebastian Korotkiewicz <skorotkiewicz@gmail.com> This commit was signed with a verified signature.
| |
| commit | b5066088445be68405dc13d65a41ac9d2de0f784 (patch) | |
| tree | 08fd90f6b5a6f29693c2a9df00b21af37694c23a | |
| parent | ce0a0200c405f2b649843be1f5378fd0b1d297a7 (diff) | |
| download | aurcade-b5066088445be68405dc13d65a41ac9d2de0f784.tar.gz aurcade-b5066088445be68405dc13d65a41ac9d2de0f784.zip | |
Add cgit caching support
Configure cgit with cache settings (root, size, TTLs) and add lighttpd
expire module for static asset caching. Entrypoint script now creates
and cleans the cgit cache directory on startup.
| -rw-r--r-- | Cargo.lock | 2 | ||||
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | docker/entrypoint.sh | 2 | ||||
| -rw-r--r-- | docker/lighttpd.conf | 7 | ||||
| -rw-r--r-- | src/main.rs | 2 |
5 files changed, 10 insertions, 5 deletions
@@ -4,7 +4,7 @@ version = 4 [[package]] name = "aurcade" -version = "0.2.1" +version = "0.2.2" dependencies = [ "serde", "toml", @@ -1,6 +1,6 @@ [package] name = "aurcade" -version = "0.2.1" +version = "0.2.2" edition = "2024" [dependencies] diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index a9b3004..e3fb86b 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -5,6 +5,8 @@ set -eu export AURCADE_ROOT aurcade setup +install -d -m 700 -o lighttpd -g lighttpd /var/cache/cgit +find /var/cache/cgit -mindepth 1 -delete chown -R git:git "$AURCADE_ROOT" /home/git/.ssh chown -R lighttpd:lighttpd /etc/aurcade/signing host_key=/etc/ssh/host_keys/ssh_host_ed25519_key diff --git a/docker/lighttpd.conf b/docker/lighttpd.conf index e5cb29c..a0508d6 100644 --- a/docker/lighttpd.conf +++ b/docker/lighttpd.conf @@ -1,4 +1,4 @@ -server.modules = ( "mod_cgi", "mod_rewrite", "mod_setenv" ) +server.modules = ( "mod_cgi", "mod_expire", "mod_rewrite", "mod_setenv" ) server.document-root = "/usr/share/webapps/cgit" server.port = 80 server.bind = "0.0.0.0" @@ -17,6 +17,9 @@ setenv.add-environment = ( "GIT_CONFIG_KEY_2" => "gpg.ssh.program", "GIT_CONFIG_VALUE_2" => "/usr/bin/ssh-keygen" ) -$HTTP["url"] !~ "^/([A-Za-z0-9._-]+[.](css|gif|jpe?g|png|svg|webp)|cgit[.]cgi|favicon[.]ico|robots[.]txt)(/|$)" { +$HTTP["url"] =~ "^/([A-Za-z0-9._-]+[.](css|gif|jpe?g|js|png|svg|webp)|favicon[.]ico|robots[.]txt)$" { + expire.url = ( "" => "access plus 1 hours" ) +} +$HTTP["url"] !~ "^/([A-Za-z0-9._-]+[.](css|gif|jpe?g|js|png|svg|webp)|cgit[.]cgi|favicon[.]ico|robots[.]txt)(/|$)" { url.rewrite-once = ( "^/(.*)$" => "/cgit.cgi/$1" ) } diff --git a/src/main.rs b/src/main.rs index 60b8c28..901a32a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -447,7 +447,7 @@ fn write_cgit_config(config: &Config, root: &Path) -> Result<(), Error> { .map(PathBuf::from) .unwrap_or_else(|| root.join("cgitrc")); let mut output = format!( - "root-title={}\nroot-desc={}\nvirtual-root=/\nclone-prefix={}\ncss={}\nlogo={}\nmimetype-file=/etc/mime.types\nabout-filter=/usr/local/bin/aurcade-about-filter\nsource-filter=/usr/lib/cgit/filters/syntax-highlighting.sh\nenable-http-clone=1\nsnapshots=tar.gz zip\nreadme=:README.md\nreadme=:README\n", + "root-title={}\nroot-desc={}\nvirtual-root=/\nclone-prefix={}\ncss={}\nlogo={}\nmimetype-file=/etc/mime.types\nabout-filter=/usr/local/bin/aurcade-about-filter\nsource-filter=/usr/lib/cgit/filters/syntax-highlighting.sh\nenable-http-clone=1\nsnapshots=tar.gz zip\ncache-root=/var/cache/cgit\ncache-size=1000\ncache-dynamic-ttl=1\ncache-repo-ttl=1\ncache-root-ttl=1\ncache-about-ttl=1\nreadme=:README.md\nreadme=:README\n", config.title, config.description, config.clone_prefix, |