Wired URL rewriting issues
while I goto
it works fine, repos shows up. However the links on that page appended /foo again i.e.
When I goto URL like
It works, but each links on that page looks like
Here is my nginx.conf, did I miss something?
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!!
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;
}
This isn't anything to do with Nginx, there's a bug in the code generating your URLs.
On the page http://git.example.org/foo you have a link written as:
It should either be absolute to the server as:
Or relative to the current directory as:
Presumably somewhere in the code where you init cgit you are pasing in
foo
where you should be passing in/foo
.