From 1cb80b2d9f3245bfc9e3f02f84b6af681054131a Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Sun, 15 Dec 2024 19:42:53 +0800 Subject: add cgit --- nginx/nginx.conf | 2 +- nginx/sites-available/vps | 52 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 40 insertions(+), 14 deletions(-) (limited to 'nginx') diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 605f056..f94c508 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -33,7 +33,7 @@ http { # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; log_format main '$status $request_method\t$http_host$uri\tfrom $http_referer\n' - ' $time_iso8601 $remote_addr\r\t\t\t\t\t $http_user_agent'; + ' $time_iso8601 $remote_addr\r\t\t\t\t\t $http_user_agent'; access_log /var/log/nginx/access.log main; sendfile on; diff --git a/nginx/sites-available/vps b/nginx/sites-available/vps index 75a789b..3985072 100644 --- a/nginx/sites-available/vps +++ b/nginx/sites-available/vps @@ -16,7 +16,7 @@ map $uri $basename { } server { - server_name topo.tw www.topo.tw "~[\d\.]+"; + server_name topo.tw www.topo.tw "~[\d\.]+" localhost; listen 80; listen 443 ssl; @@ -54,7 +54,13 @@ server { error_log /var/log/nginx/error.log debug; #rewrite_log on; - location ~ \.html$ { + # RSS Feed for various names + # ref: https://blog.jim-nielsen.com/2021/feed-urls/ + location ^~ (index.xml|atom.xml|feed.xml|feed.atom)$ { + alias /srv/http/feed.rss; + } + + location ^~ \.html$ { try_files $uri =404; } @@ -68,11 +74,11 @@ server { fancyindex_ignore Makefile fastcgi.*; } - location ~ /cgi/(.*) { + location ^~ /cgi/ { gzip off; include /etc/nginx/fastcgi_params; - fastcgi_pass unix:/srv/cgi/fastcgi.sock; - fastcgi_param SCRIPT_FILENAME /srv/cgi/$1; + fastcgi_pass unix:/run/fcgiwrap.sock; + fastcgi_param SCRIPT_FILENAME /srv/cgi/$basename; error_log /tmp/cgi info; } @@ -317,15 +323,35 @@ server { ssl_certificate /etc/nginx/ssl/git.topo.tw/fullchain.cer; ssl_certificate_key /etc/nginx/ssl/git.topo.tw/git.topo.tw.key; - root /srv/git/www; + root /usr/share/webapps/cgit; + try_files $uri @cgit; + + location = /favicon.ico { + alias /srv/http/favicon.ico; + } + + location = /logo.svg { + alias /home/pham/site/git/logo.svg; + } + + # Configure HTTP transport + location ~ /.+/(info/refs|git-upload-pack) { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; + fastcgi_param PATH_INFO $uri; + fastcgi_param GIT_HTTP_EXPORT_ALL 1; + fastcgi_param GIT_PROJECT_ROOT /srv/git; + fastcgi_param HOME /srv/git; + fastcgi_pass unix:/run/fcgiwrap.sock; + } - location ~ (/.*) { - #include fastcgi_params; - #fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; - ## export all repositories under GIT_PROJECT_ROOT - #fastcgi_param GIT_HTTP_EXPORT_ALL ""; - #fastcgi_param GIT_PROJECT_ROOT /srv/git; - #fastcgi_param PATH_INFO $1; + location @cgit { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/local/lib/cgit/cgit.cgi; + fastcgi_param PATH_INFO $uri; + fastcgi_param QUERY_STRING $args; + fastcgi_param HTTP_HOST $server_name; + fastcgi_pass unix:/run/fcgiwrap.sock; } } -- cgit v1.2.3-70-g09d2