diff options
| author | saturneric <[email protected]> | 2025-11-07 23:54:52 +0000 |
|---|---|---|
| committer | saturneric <[email protected]> | 2025-11-07 23:54:52 +0000 |
| commit | 754e7af1b00989e7330820fcc1aaada1cc291231 (patch) | |
| tree | c82f55dd229dd0df5fba2f58f89ee98ab45f9cf1 | |
| parent | chore(docker): update base image to custom alpine (diff) | |
| download | cgit-754e7af1b00989e7330820fcc1aaada1cc291231.tar.gz cgit-754e7af1b00989e7330820fcc1aaada1cc291231.zip | |
refactor(config): improve proxy and rewrite logic
* Normalize directory paths and index file configuration for
consistency and clarity
* Refine proxy server block for git HTTP requests, using clearer
structure and comments
* Scope URL rewrite rules to non-proxied requests, improving asset
handling and compatibility with virtual root setups
| -rw-r--r-- | lighttpd.conf | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/lighttpd.conf b/lighttpd.conf index c103439..f68c3e8 100644 --- a/lighttpd.conf +++ b/lighttpd.conf @@ -1,24 +1,34 @@ server.port = 80 -server.document-root = "/usr/share/webapps/cgit" -index-file.names = ( "cgit.cgi" ) - +server.document-root = "/usr/share/webapps/cgit/" +server.indexfiles = ("cgit.cgi") server.modules += ( "mod_access", "mod_alias", "mod_cgi", "mod_rewrite", "mod_proxy", "mod_accesslog" ) -cgi.assign = ( ".cgi" => "" ) + +cgi.assign = ("cgit.cgi" => "") mimetype.assign = ( ".css" => "text/css" ) # log to stderr accesslog.filename = "/dev/stderr" accesslog.format = "%h %V %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-Agent}i\" %T" -# reserve proxy for gitea git service +# Proxy git http requests to gitea $HTTP["url"] =~ "^/(.+?)\.git/(info/refs|git-upload-pack)$" { $HTTP["request-method"] !~ "^(GET|POST)$" { - url.access-deny = ( "" ) + url.access-deny = ("") } - proxy.server = ( "" => ( ( "host" => "gitea", "port" => 3000 ) ) ) + + proxy.server = ( + "" => (( + "host" => "gitea", + "port" => 3000, + )) + ) } +else $HTTP["url"] =~ "^/" { + -# rewrite all requests to cgit.cgi except for static files -url.rewrite-once = ( - "^/((?!cgit\.(css|png)$)(?!favicon\.ico$)(?!robots\.txt$).*)$" => "/cgit.cgi/$1" -)
\ No newline at end of file + # Rewrite any other url but the asset urls to be handled by the cgit + # executable. Use with virtual-root=/ cgitrc setting. + url.rewrite-once = ( + "^/((?!cgit\.(css|png)$)(?!favicon\.ico$)(?!robots\.txt$).*)$" => "/cgit.cgi/$1" + ) +}
\ No newline at end of file |
