From ee9c98c4017702c839d1ed07eaa6a4166ca28f95 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Tue, 17 Dec 2024 00:18:41 +0800 Subject: nginx: update --- nginx/nginx.conf | 2 +- nginx/sites-available/vps | 58 ++++++++++++++++++++++++----------------------- 2 files changed, 31 insertions(+), 29 deletions(-) (limited to 'nginx') diff --git a/nginx/nginx.conf b/nginx/nginx.conf index f94c508..1b6d9ed 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_local $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 3985072..820f346 100644 --- a/nginx/sites-available/vps +++ b/nginx/sites-available/vps @@ -56,11 +56,21 @@ server { # RSS Feed for various names # ref: https://blog.jim-nielsen.com/2021/feed-urls/ - location ^~ (index.xml|atom.xml|feed.xml|feed.atom)$ { + location ~ (rss|index.xml|atom.xml|feed|feed.xml|feed.atom)$ { alias /srv/http/feed.rss; + add_header Content-Type "text/xml; charset=utf-8"; } - location ^~ \.html$ { + location ~ [^/]$ { + try_files $uri @rewrite_no_slash; + } + + location @rewrite_no_slash { + add_header rewrite no_slash; + rewrite ^(.+)$ $1.html permanent; + } + + location ~ \.html$ { try_files $uri =404; } @@ -86,15 +96,6 @@ server { alias /srv/rss/; } - location ~ [^/]$ { - try_files $uri @rewrite_no_slash; - } - - location @rewrite_no_slash { - add_header rewrite no_slash; - rewrite ^(.+)$ $1.html permanent; - } - #location ~ /$ { # try_files $uri @rewrite_slash; #} @@ -326,6 +327,15 @@ server { root /usr/share/webapps/cgit; try_files $uri @cgit; + 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; + } + location = /favicon.ico { alias /srv/http/favicon.ico; } @@ -335,24 +345,16 @@ server { } # 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 ~ /.+/(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 @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; - } } # Block all direct accesses via IP address -- cgit v1.2.3-70-g09d2