gpt4 book ai didi

nginx - Cgit 和 Nginx URL 重写

转载 作者:行者123 更新时间:2023-12-01 05:21:40 33 4
gpt4 key购买 nike

有线 URL 重写问题

当我去

http://git.example.org/foo



它工作正常, repo 出现。但是,该页面上的链接再次附加了/foo
IE。

http://git.example.org/foo/foo/commit



当我转到 URL 时

http://git.example.org/foo/commit?id=123123



它有效,但该页面上的每个链接看起来像

http://git.example.org/foo/commit/foo/snapshot/foo/4f0be51d35fe3160a9122894723b69df69a6fb7e.zip?id=4f0be51d35fe3160a9122894723b69df69a6fb7e



这是我的 nginx.conf,我错过了什么吗?
server {
listen 80;
server_name git.example.org;
root /var/www/htdocs/cgit;
index cgit.cgi;

location ~* ^.+\.(css|png|ico)$ {
expires 30d;
}

if ($request_filename = cgit.cgi){
rewrite ^/([^/]+/.*)$ /cgit.cgi?url=$1 last;
}

location / {
try_files $uri @cgit;
}

location @cgit {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
fastcgi_param HTTP_HOST $server_name;
fastcgi_param PATH_INFO $uri;
include fastcgi_params;

}
access_log /var/log/nginx/cgit_access.log;
error_log /var/log/nginx/cgit_error.log warn;
}

更新,已解决

这是 virtual-root=/的 cgit 设置
我也更新了我的 nginx.conf,现在可以重写 url 了!!
server {
listen 80;
server_name git.mengzhuo.org;
root /var/www/htdocs/cgit;

location ~* ^.+\.(css|png|ico)$ {
expires 30d;
}


location / {
index cgit.cgi;
fastcgi_param SCRIPT_FILENAME $document_root/cgit.cgi;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param HTTP_HOST $server_name;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_INFO $uri;
include "fastcgi_params";

}
access_log /var/log/nginx/cgit_access.log;
error_log /var/log/nginx/cgit_error.log warn;
}

最佳答案

设置 virtual-root=/在/etc/cgitrc 中为我解决了这个问题。

关于nginx - Cgit 和 Nginx URL 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16182421/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com