[英]Cgit and Nginx URL rewrite
Wired URL rewriting issues 有线URL重写问题
while I goto 我转到的时候
it works fine, repos shows up. 它工作正常,回购显示。 However the links on that page appended /foo again ie
然而,该页面上的链接再次附加/ foo,即
http://git.example.org/foo/foo/commit
http://git.example.org/foo/foo/commit
When I goto URL like 当我转到URL时
http://git.example.org/foo/commit?id=123123
http://git.example.org/foo/commit?id=123123
It works, but each links on that page looks like 它有效,但该页面上的每个链接看起来都像
http://git.example.org/foo/commit/foo/snapshot/foo/4f0be51d35fe3160a9122894723b69df69a6fb7e.zip?id=4f0be51d35fe3160a9122894723b69df69a6fb7e
http://git.example.org/foo/commit/foo/snapshot/foo/4f0be51d35fe3160a9122894723b69df69a6fb7e.zip?id=4f0be51d35fe3160a9122894723b69df69a6fb7e
Here is my nginx.conf, did I miss something? 这是我的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;
}
Update, SOLVED 更新,已解决
it's cgit setting of virtual-root=/ And I updated my nginx.conf too, urls rewrite works now!! 它的cgit设置virtual-root = /我也更新了我的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=/
in / etc / cgitrc为我解决了这个问题。
This isn't anything to do with Nginx, there's a bug in the code generating your URLs. 这与Nginx没有任何关系,生成URL的代码中存在一个错误。
On the page http://git.example.org/foo you have a link written as: 在http://git.example.org/foo页面上,您有一个链接写为:
<a href="foo/commit">Click to commit</a>
It should either be absolute to the server as: 它应该是服务器绝对的:
<a href="/foo/commit">Click to commit</a>
Or relative to the current directory as: 或者相对于当前目录为:
<a href="commit">Click to commit</a>
Presumably somewhere in the code where you init cgit you are pasing in foo
where you should be passing in /foo
. 大概在代码中你初始化cgit的地方,你在
foo
中你应该传入/foo
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.