You are not logged in.

#1 2015-03-12 14:16:44

alloyD
Member
Registered: 2014-04-05
Posts: 4

[SOLVED] Cgit with Nginx and fcgiwrap - no repositories found

I'm attempting to get cgit running on a VM and I'm having trouble getting cgit to see my repositories.
If I run cgit manually as the http user, the html that is generated appears to be have all the repositories, but when nginx serves the page via fcgiwrap, the page is generated, but I get "No repositories found" in the list.
The timestamp at the bottom of the page is correct and updates with a refresh which makes me think that the fcgiwrap is actually running the script, but somewhere I have an issue.

If cgit or fcgiwrap were to generate an error while searching for repositories, where would it show up?
I've modified my fcgiwrap.service file to run fcgiwrap -f so that it outputs errors to the nginx

selection from /etc/nginx/nginx.conf:

 server {
 36         listen       80;
 37         server_name  localhost;
 38 
 39         #charset koi8-r;
 40 
 41         #access_log  logs/host.access.log  main;
 42         root /srv/http/www;
 43 
 44         location / {
 45             index  index.html index.htm;
 46         }
 47         
 48         location /gitweb {
 49                 index gitweb.cgi;
 50                 include fastcgi_params;
 51                 gzip off;
 52                 fastcgi_param   GITWEB_CONFIG /etc/conf.d/gitweb.conf;
 53                 fastcgi_pass unix:/run/fcgiwrap.sock;
 54         }
 55 
 56         location /git {
 57                 try_files $uri @cgit;
 58         }
 59 
 60         location @cgit {
 61 #                gzip off;
 62 #                include uwsgi_params;
 63 #                uwsgi_modifier1 9;
 64 #                uwsgi_pass unix:/run/uwsgi/cgit.sock;
 65                 include fastcgi_params;
 66                 fastcgi_param   SCRIPT_FILENAME $document_root/git/cgit.cgi;
 67                 fastcgi_param   PATH_INFO       $uri;
 68                 fastcgi_param   QUERY_STRING    $args;
 69                 fastcgi_param   HTTP_HOST       $server_name;
 70                 fastcgi_pass    unix:/run/fcgiwrap.sock;
 71         }

Last edited by alloyD (2015-03-22 21:45:37)

Offline

#2 2015-03-21 21:25:50

femtonaut
Member
Registered: 2015-03-21
Posts: 1

Re: [SOLVED] Cgit with Nginx and fcgiwrap - no repositories found

It has something to do with needing to do a URL rewrite.

I'm facing a similar situation with a similar configuration to yours. I notice if I write the right query string it sort of works.
So for your example point your browser to http://host/git/?url=/ and you should see your repositories.
http://host/git/?url=reponame should show you reponame.

Anyhow, I've set cgit up with lighttpd as per the wiki page:
https://wiki.archlinux.org/index.php/Cgit#Lighttpd

Notice the url rewrite in the example configuration:

     url.rewrite-once     = (
       "^/([^?/]+/[^?]*)?(?:\?(.*))?$"   => "/cgit.cgi?url=$1&$2",
     )

I think we just need to figure out how to do the same rewrite with nginx.
I'll keep trying and report back.

Offline

#3 2015-03-22 12:57:27

alloyD
Member
Registered: 2014-04-05
Posts: 4

Re: [SOLVED] Cgit with Nginx and fcgiwrap - no repositories found

Whoa! Adding" ?url=/ " to the url made cgit work properly. This definitely gets me moving in the right direction for a permanent fix. Can anyone explain the reason for this to me?

Once I get it working, I'll post a working configuration and maybe add a note to the wiki.

Offline

#4 2015-03-22 13:46:46

progandy
Member
Registered: 2012-05-17
Posts: 5,219

Re: [SOLVED] Cgit with Nginx and fcgiwrap - no repositories found

I think you should use "virtual-root" in your cgitrc instead. cgit might get confused if you run it in a subdirectory.

The example from the cgit page in the archwiki worked for me without any problems. I just copied the config from "Using fcgiwrap" (custom server_name), and "Basic Configuration" (with scan-path)
https://wiki.archlinux.org/index.php/Cgit

Last edited by progandy (2015-03-22 13:49:41)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#5 2015-03-22 21:45:07

alloyD
Member
Registered: 2014-04-05
Posts: 4

Re: [SOLVED] Cgit with Nginx and fcgiwrap - no repositories found

Thanks, guys, for pointing me in the right direction. Seems like the problem is that I'm running cgit in a subdirectory. Taking a pointer from this site http://www.christophbrill.de/?q=node/39 I was able to get it working consistently.

Here's the relevant part of my nginx config. Note the fastcgi_split_path_info and fastcgi_param PATH_INFO lines:

         location @cgit {
                 include fastcgi_params;
                 fastcgi_param   SCRIPT_FILENAME $document_root/git/cgit.cgi;
                 fastcgi_split_path_info   ^(/git/?)(.+)$;
                 fastcgi_param   PATH_INFO       $fastcgi_path_info;
                 fastcgi_param   QUERY_STRING    $args;
                 fastcgi_param   HTTP_HOST       $server_name;
                 fastcgi_pass    unix:/run/fcgiwrap.sock;
         }

Offline

Board footer

Powered by FluxBB