summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArseney300 <Arseney300@gmail.com>2026-02-21 03:41:20 +0700
committerArseney300 <Arseney300@gmail.com>2026-02-21 03:41:20 +0700
commit5ada368fe2f37ae4e570c2707d7a8d0d547e9f2d (patch)
tree9829a9deedbca19d45a80a9629b8a1564916a6de
parent201045912d00b33ecb1d9cc0897579d45996db16 (diff)
Fix cgit links when accessed via swave.lol/cgit path
Use sub_filter to rewrite href/action attributes (both quote styles) to include /cgit prefix, and proxy_redirect to catch cgit's HTTP redirects. Fixes broken navigation on path-based access while leaving cgit.swave.lol subdomain unaffected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
-rw-r--r--nginx/nginx.conf12
1 files changed, 12 insertions, 0 deletions
diff --git a/nginx/nginx.conf b/nginx/nginx.conf
index ea83fd1..8112e28 100644
--- a/nginx/nginx.conf
+++ b/nginx/nginx.conf
@@ -54,12 +54,24 @@ server {
}
# Cgit via path prefix on main domain
+ # cgit generates links from virtual-root=/ so we rewrite them to /cgit/
location /cgit {
proxy_pass http://cgit:80/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
+
+ # Rewrite cgit links to include /cgit prefix
+ sub_filter 'href="/' 'href="/cgit/';
+ sub_filter "href='/" "href='/cgit/";
+ sub_filter 'action="/' 'action="/cgit/';
+ sub_filter "action='/" "action='/cgit/";
+ sub_filter_once off;
+ sub_filter_types text/html;
+
+ # Rewrite any redirects from cgit itself
+ proxy_redirect / /cgit/;
}
# Gerrit via path prefix on main domain