From 8b63e61068efedd325e3458aa75eddf244d1be5d Mon Sep 17 00:00:00 2001 From: Xiao Pan Date: Sun, 3 Mar 2024 01:17:41 +0000 Subject: maybe improve nginx.conf location regex a little bit --- etc/nginx/nginx.conf | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'etc') diff --git a/etc/nginx/nginx.conf b/etc/nginx/nginx.conf index 17b23af5..011a9b52 100644 --- a/etc/nginx/nginx.conf +++ b/etc/nginx/nginx.conf @@ -163,8 +163,17 @@ http { ssl_certificate /etc/nginx/flylightning.pem; ssl_certificate_key /etc/nginx/flylightning.key; + # about nginx location regex: + # - https://nginx.org/en/docs/http/ngx_http_core_module.html#location + # - https://stackoverflow.com/a/59846239 + # - note in nginx / only means / and no other meaning, so no need \/ + # - ~ means case-sensitive regex + # about (?:) non-capturing group: + # - https://manifold.net/doc/radian/why_do_non-capture_groups_exist_.htm + # - non-capturing group won't capture things inside () which may use later like in sed \1 + # - maybe improve a little bit performance by not storing things (not tested, also I did not read the source code) # Serve static files with nginx - location ~* ^.+(cgit.(css|png)|favicon.ico|robots.txt|highlight.css|mycgit.css) { + location ~ ^/(?:cgit\.(?:css|png)|favicon\.ico|robots\.txt|highlight\.css|mycgit\.css)$ { root /usr/share/webapps/cgit; expires 30d; } -- cgit v1.2.3-70-g09d2