From 756dc388bedf97b68449e919a6730788f730c7b8 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Thu, 16 Jul 2026 14:39:19 +0200 Subject: Refactor pve cgit to use generic proxy This is refactoring the PoC for deploying cgit on pve, to now move to a more standard deployment with dedicated agnonstic proxy role/container --- roles/cgit/templates/cgit.caddy.j2 | 3 +++ roles/cgit/templates/cgit.lighttpd.conf.j2 | 24 ++++++++++++++++++++++++ roles/cgit/templates/cgit.nginx.conf.j2 | 25 ++++++++++++++----------- roles/cgit/templates/cgitrc.j2 | 4 ++-- 4 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 roles/cgit/templates/cgit.caddy.j2 create mode 100644 roles/cgit/templates/cgit.lighttpd.conf.j2 (limited to 'roles/cgit/templates') diff --git a/roles/cgit/templates/cgit.caddy.j2 b/roles/cgit/templates/cgit.caddy.j2 new file mode 100644 index 00000000..8ddc6d88 --- /dev/null +++ b/roles/cgit/templates/cgit.caddy.j2 @@ -0,0 +1,3 @@ +{{ cgit_hostname }} { + reverse_proxy {{ network_ipv4_address }}:{{ cgit_port }} +} diff --git a/roles/cgit/templates/cgit.lighttpd.conf.j2 b/roles/cgit/templates/cgit.lighttpd.conf.j2 new file mode 100644 index 00000000..0fd1d535 --- /dev/null +++ b/roles/cgit/templates/cgit.lighttpd.conf.j2 @@ -0,0 +1,24 @@ +server.port = {{ cgit_port }} +server.bind = "{{ network_ipv4_address }}" +server.modules = ("mod_cgi", "mod_rewrite") + +server.document-root = "/usr/share/webapps/cgit" +server.pid-file = "/run/lighttpd.pid" + +mimetype.assign = ( + ".css" => "text/css", + ".png" => "image/png", + ".ico" => "image/x-icon", + ".txt" => "text/plain", + ".html" => "text/html", +) + +cgi.assign = (".cgi" => "") + +url.rewrite-once = ( + "^/cgit\.css$" => "/cgit.css", + "^/cgit\.png$" => "/cgit.png", + "^/favicon\.ico$" => "/favicon.ico", + "^/robots\.txt$" => "/robots.txt", + "^(/.*)?$" => "/cgit.cgi$1", +) diff --git a/roles/cgit/templates/cgit.nginx.conf.j2 b/roles/cgit/templates/cgit.nginx.conf.j2 index 14256054..62fa6669 100644 --- a/roles/cgit/templates/cgit.nginx.conf.j2 +++ b/roles/cgit/templates/cgit.nginx.conf.j2 @@ -1,19 +1,22 @@ server { - listen {{ cgit_port }}; - listen [::]:{{ cgit_port }}; + listen 80; + listen [::]:80; server_name {{ cgit_hostname }}; - root /usr/share/webapps/cgit; + return 301 https://$server_name$request_uri; +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + + server_name {{ cgit_hostname }}; - try_files $uri @cgit; + ssl_certificate {{ nginx_ssl_certificate }}; + ssl_certificate_key {{ nginx_ssl_certificate_key }}; - location @cgit { - fastcgi_pass unix:/run/fcgiwrap/fcgiwrap.sock; - fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi; - fastcgi_param PATH_INFO $uri; - fastcgi_param QUERY_STRING $args; - fastcgi_param HTTP_HOST $server_name; - include fastcgi_params; + location / { + proxy_pass http://{{ network_ipv4_address }}:{{ cgit_port }}; } } diff --git a/roles/cgit/templates/cgitrc.j2 b/roles/cgit/templates/cgitrc.j2 index a23e2d0b..89578a7c 100644 --- a/roles/cgit/templates/cgitrc.j2 +++ b/roles/cgit/templates/cgitrc.j2 @@ -1,5 +1,5 @@ -css=/cgit/cgit.css -logo=/cgit/cgit.png +css=/cgit.css +logo=/cgit.png virtual-root=/ -- cgit v1.2.3