{"thread":{"id":"30152","subject":"Static gitweb content when using pathinfo","startedAt":"2012-04-05T13:54:27Z","lastAt":"2012-04-24T07:01:46Z","messageCount":6,"participants":["José María Escartín Esteban","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"188563","messageId":"4F7DA413.2020502@gmail.com","threadId":"30152","inReplyTo":null,"subject":"Static gitweb content when using pathinfo","fromName":"José María Escartín Esteban","fromEmail":"ripero84@gmail.com","sentAt":"2012-04-05T13:54:27Z","receivedAt":"2012-04-05T13:54:27Z","isPatch":false,"sender":{"key":"ripero84@gmail.com","avatar":"https://gravatar.com/avatar/bcfe92ac2883f73dc13aa100b0cc85092ca55a3c9e441f9a7b4bab1303b5f9fa?d=mp&s=160"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nHi,\n\nI'm running gitweb in a server.example.com/gitweb/ scenario.  If I don't enable\npathinfo everything works fine, but when I enable pathinfo the static content\nstops showing up in the browser.\n\nI'm not an HTML or perl expert, but I think that this may be due to a missing\nslash in the construction of the base tag:  Using the upstream script I am getting\n\n<base href=\"http://server.example.com/gitweb\" />\n\nand no static content.  Once I tune the script to add a final slash to the url\n\n<base href=\"http://server.example.com/gitweb/\" />\n\nthe static content shows up again.\n\nMaybe I'm doing something wrong (am I?), and possibly this can be solved from\nthe web server side, but maybe it also makes some sense to include in the script\nsome check that the url used in the base tag ends with a slash.  In that case,\ngiven my lack of perl skills, I would be really grateful if somebody implemented it.\n\nThank you for your attention.\n\nGreetings,\n\n\tE.\n\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.11 (GNU/Linux)\n\niEYEARECAAYFAk99pBMACgkQY+7weQMem3y28wCeOotCIgFF8sT4LKgq599IhB/E\n0qcAn2dri0Z61PjV90bxfBG1QMFD3c75\n=6PBz\n-----END PGP SIGNATURE-----\n"},{"id":"188596","messageId":"201204052314.10606.jnareb@gmail.com","threadId":"30152","inReplyTo":"4F7DA413.2020502@gmail.com","subject":"Re: Static gitweb content when using pathinfo","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-04-05T21:14:09Z","receivedAt":"2012-04-05T21:14:09Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Thu, 5 Apr 2012, José María Escartín Esteban wrote:\n> Hi,\n> \n> I'm running gitweb in a server.example.com/gitweb/ scenario.  If I don't enable\n> pathinfo everything works fine, but when I enable pathinfo the static content\n> stops showing up in the browser.\n> \n> I'm not an HTML or perl expert, but I think that this may be due to a missing\n> slash in the construction of the base tag:  Using the upstream script I am getting\n> \n> <base href=\"http://server.example.com/gitweb\" />\n> \n> and no static content.  Once I tune the script to add a final slash to the url\n> \n> <base href=\"http://server.example.com/gitweb/\" />\n> \n> the static content shows up again.\n> \n> Maybe I'm doing something wrong (am I?), and possibly this can be solved from\n> the web server side, but maybe it also makes some sense to include in the script\n> some check that the url used in the base tag ends with a slash.  In that case,\n> given my lack of perl skills, I would be really grateful if somebody implemented it.\n\nHow do you deploy gitweb, what is your web server configuration, and\nwhat is the URL of main gitweb page (using placeholders like 'example.com'\nor 'foo')?\n\nWhen I am running gitweb, it uses http://localhost/cgi-bin/gitweb/gitweb.cgi\nURL, and BASE element for path_info is\n\n  <base href=\"http://localhost/cgi-bin/gitweb/gitweb.cgi\" />\n\nNote that last component of 'href' attribute of base element is the\nbasename of script, which according to HTML 4.01[1] and RFC 3986[2]\nis removed[3]\n\n   o  return a string consisting of the reference's path component\n      appended to all but the last segment of the base URI's path (i.e.,\n      excluding any characters after the right-most \"/\" in the base URI\n      path, or excluding the entire base URI path if it does not contain\n      any \"/\" characters).\n\n\nThere might be problem if you configured your web server to serve gitweb\nusing it as a handler for subdirectory, so the script name does not need\nto appear in URL, e.g.\n\n  http://localhost/cgi-bin/gitweb\n\nwhich would require the following base element\n\n  <base href=\"http://localhost/cgi-bin/gitweb/\" />\n\nGitweb would have to distinguish those two cases somehow, and either add\nor not add trailing slash '/'.\n\n[1]: http://www.w3.org/TR/html401/struct/links.html#h-12.4\n[2]: http://tools.ietf.org/html/rfc3986#section-5.2\n[3]: http://tools.ietf.org/html/rfc3986#section-5.2.3\n\n> Once I tune the script to add a final slash to the url\n> \n> <base href=\"http://server.example.com/gitweb/\" />\n> \n> the static content shows up again.\n\nBy \"tune the script\" do you mean editing gitweb.cgi, or adding setting\n$base_url to gitweb configuration file, see gitweb.conf(5):\n\n  $base_url\n     Base  URL  for  relative  URLs  in  pages generated by gitweb, (e.g.\n     $logo, $favicon, @stylesheets if they are relative URLs), needed and\n     used  <base href=\"$base_url\"> only for URLs with nonempty PATH_INFO.\n     Usually gitweb sets its value correctly, and there is no need to set\n     this  variable,  e.g.  to $my_uri or \"/\". See $per_request_config if\n     you need to override it anyway.\n\nYou can e.g. put\n\n  $base_url .= '/' unless ($base_url =~ m!/$!);\n\nin the gitweb configuration file to ensure that it ends with '/', whatever\nit is.\n\nHTH\n-- \nJakub Narebski\nPoland\n"},{"id":"189265","messageId":"201204141919.19285.jnareb@gmail.com","threadId":"30152","inReplyTo":"201204052314.10606.jnareb@gmail.com","subject":"Re: Static gitweb content when using pathinfo","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-04-14T17:19:18Z","receivedAt":"2012-04-14T17:19:18Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Thu, 5 Apr 2012, Jakub Narebski wrote:\n> On Thu, 5 Apr 2012, José María Escartín Esteban wrote:\n> > Hi,\n> > \n> > I'm running gitweb in a server.example.com/gitweb/ scenario.  If I don't enable\n> > pathinfo everything works fine, but when I enable pathinfo the static content\n> > stops showing up in the browser.\n> > \n> > I'm not an HTML or perl expert, but I think that this may be due to a missing\n> > slash in the construction of the base tag:  Using the upstream script I am getting\n> > \n> > <base href=\"http://server.example.com/gitweb\" />\n> > \n> > and no static content.  Once I tune the script to add a final slash to the url\n> > \n> > <base href=\"http://server.example.com/gitweb/\" />\n> > \n> > the static content shows up again.\n>\n> How do you deploy gitweb, what is your web server configuration, and\n> what is the URL of main gitweb page (using placeholders like 'example.com'\n> or 'foo')?\n\nPing?\n\n[...]\n\n> There might be problem if you configured your web server to serve gitweb\n> using it as a handler for subdirectory, so the script name does not need\n> to appear in URL, e.g.\n> \n>   http://localhost/cgi-bin/gitweb\n> \n> which would require the following base element\n> \n>   <base href=\"http://localhost/cgi-bin/gitweb/\" />\n\n[...]\n\n> > Once I tune the script to add a final slash to the url\n> > \n> > <base href=\"http://server.example.com/gitweb/\" />\n> > \n> > the static content shows up again.\n> \n> By \"tune the script\" do you mean editing gitweb.cgi, or adding setting\n> $base_url to gitweb configuration file, see gitweb.conf(5):\n> \n>   $base_url\n>      Base  URL  for  relative  URLs  in  pages generated by gitweb, (e.g.\n>      $logo, $favicon, @stylesheets if they are relative URLs), needed and\n>      used  <base href=\"$base_url\"> only for URLs with nonempty PATH_INFO.\n>      Usually gitweb sets its value correctly, and there is no need to set\n>      this  variable,  e.g.  to $my_uri or \"/\". See $per_request_config if\n>      you need to override it anyway.\n> \n> You can e.g. put\n> \n>   $base_url .= '/' unless ($base_url =~ m!/$!);\n> \n> in the gitweb configuration file to ensure that it ends with '/', whatever\n> it is.\n\nBy the way, would the following proposed addition to gitweb.conf(5)\nmanpage would help your situation?\n\n-------- >8 ---------- >8 ---------\nSubject: [PATCH/RFC] gitweb.conf(5): When to set $base_url\n\nAdd a paragraph to description of $base_url variable in gitweb.conf(5)\nmanpage explaining when and why one might need to set it.\n\nBased-on-report-by: José María Escartín Esteban <ripero84@gmail.com>\nSigned-off-by: Jakub Narebski <jnareb@gmail.com>\n---\n Documentation/gitweb.conf.txt |   14 ++++++++++++++\n 1 files changed, 14 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt\nindex 7aba497..a2a6ddf 100644\n--- a/Documentation/gitweb.conf.txt\n+++ b/Documentation/gitweb.conf.txt\n@@ -559,6 +559,20 @@ $base_url::\n \tPATH_INFO.  Usually gitweb sets its value correctly,\n \tand there is no need to set this variable, e.g. to $my_uri or \"/\".\n \tSee `$per_request_config` if you need to override it anyway.\n++\n+You would need to set this variable when using gitweb as a directory\n+handler and using path_info-based URLs.  For example if your web\n+server is set up in such way that full path to browse repositories is\n+`http://git.example.com/gitweb` and static files are served from\n+'/gitweb/static' directory with default values (e.g. `$logo` is\n+`static/git-logo.png`), then you would need to set `$base_url` to\n+(for example):\n++\n+----------------------------------------------------------------------\n+our $base_url = \"http://git.example.com/gitweb/\";\n+----------------------------------------------------------------------\n++\n+The trailing slash is required!\n \n \n CONFIGURING GITWEB FEATURES\n-- \n1.7.9\n"},{"id":"189413","messageId":"4F8C384C.2040109@gmail.com","threadId":"30152","inReplyTo":"201204141919.19285.jnareb@gmail.com","subject":"Re: Static gitweb content when using pathinfo","fromName":"José María Escartín Esteban","fromEmail":"ripero84@gmail.com","sentAt":"2012-04-16T15:18:36Z","receivedAt":"2012-04-16T15:18:36Z","isPatch":false,"sender":{"key":"ripero84@gmail.com","avatar":"https://gravatar.com/avatar/bcfe92ac2883f73dc13aa100b0cc85092ca55a3c9e441f9a7b4bab1303b5f9fa?d=mp&s=160"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nHi,\n\nThank you for your detailed answers, and sorry for the delay in my reply.\n\nOn 14/04/12 19:19, Jakub Narebski wrote:\n> On Thu, 5 Apr 2012, Jakub Narebski wrote:\n>> On Thu, 5 Apr 2012, José María Escartín Esteban wrote:\n>>> Hi,\n>>>\n>>> I'm running gitweb in a server.example.com/gitweb/ scenario.  If I don't enable\n>>> pathinfo everything works fine, but when I enable pathinfo the static content\n>>> stops showing up in the browser.\n>>>\n>>> I'm not an HTML or perl expert, but I think that this may be due to a missing\n>>> slash in the construction of the base tag:  Using the upstream script I am getting\n>>>\n>>> <base href=\"http://server.example.com/gitweb\" />\n>>>\n>>> and no static content.  Once I tune the script to add a final slash to the url\n>>>\n>>> <base href=\"http://server.example.com/gitweb/\" />\n>>>\n>>> the static content shows up again.\n>>\n>> How do you deploy gitweb, what is your web server configuration, and\n>> what is the URL of main gitweb page (using placeholders like 'example.com'\n>> or 'foo')?\n> \n> Ping?\n> \n> [...]\n> \n\nI'll describe the setup at the end of my email, but you already provided the\nsolution!\n\n>> There might be problem if you configured your web server to serve gitweb\n>> using it as a handler for subdirectory, so the script name does not need\n>> to appear in URL, e.g.\n>>\n>>   http://localhost/cgi-bin/gitweb\n>>\n>> which would require the following base element\n>>\n>>   <base href=\"http://localhost/cgi-bin/gitweb/\" />\n> \n> [...]\n> \n\nYes, that was precisely the problem.\n\n>>> Once I tune the script to add a final slash to the url\n>>>\n>>> <base href=\"http://server.example.com/gitweb/\" />\n>>>\n>>> the static content shows up again.\n>>\n>> By \"tune the script\" do you mean editing gitweb.cgi, or adding setting\n>> $base_url to gitweb configuration file, see gitweb.conf(5):\n>>\n>>   $base_url\n>>      Base  URL  for  relative  URLs  in  pages generated by gitweb, (e.g.\n>>      $logo, $favicon, @stylesheets if they are relative URLs), needed and\n>>      used  <base href=\"$base_url\"> only for URLs with nonempty PATH_INFO.\n>>      Usually gitweb sets its value correctly, and there is no need to set\n>>      this  variable,  e.g.  to $my_uri or \"/\". See $per_request_config if\n>>      you need to override it anyway.\n>>\n>> You can e.g. put\n>>\n>>   $base_url .= '/' unless ($base_url =~ m!/$!);\n>>\n>> in the gitweb configuration file to ensure that it ends with '/', whatever\n>> it is.\n> \n\nI was editing manually the gitweb.cgi script to add (always!) the slash.  Your\nsolution is of course better, and completely solves my problem.\n\n> By the way, would the following proposed addition to gitweb.conf(5)\n> manpage would help your situation?\n> \n> -------- >8 ---------- >8 ---------\n> Subject: [PATCH/RFC] gitweb.conf(5): When to set $base_url\n> \n> Add a paragraph to description of $base_url variable in gitweb.conf(5)\n> manpage explaining when and why one might need to set it.\n> \n> Based-on-report-by: José María Escartín Esteban <ripero84@gmail.com>\n> Signed-off-by: Jakub Narebski <jnareb@gmail.com>\n> ---\n>  Documentation/gitweb.conf.txt |   14 ++++++++++++++\n>  1 files changed, 14 insertions(+), 0 deletions(-)\n> \n> diff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt\n> index 7aba497..a2a6ddf 100644\n> --- a/Documentation/gitweb.conf.txt\n> +++ b/Documentation/gitweb.conf.txt\n> @@ -559,6 +559,20 @@ $base_url::\n>  \tPATH_INFO.  Usually gitweb sets its value correctly,\n>  \tand there is no need to set this variable, e.g. to $my_uri or \"/\".\n>  \tSee `$per_request_config` if you need to override it anyway.\n> ++\n> +You would need to set this variable when using gitweb as a directory\n> +handler and using path_info-based URLs.  For example if your web\n> +server is set up in such way that full path to browse repositories is\n> +`http://git.example.com/gitweb` and static files are served from\n> +'/gitweb/static' directory with default values (e.g. `$logo` is\n> +`static/git-logo.png`), then you would need to set `$base_url` to\n> +(for example):\n> ++\n> +----------------------------------------------------------------------\n> +our $base_url = \"http://git.example.com/gitweb/\";\n> +----------------------------------------------------------------------\n> ++\n> +The trailing slash is required!\n>  \n>  \n>  CONFIGURING GITWEB FEATURES\n\nThis addition to the man page would of course have been useful, since it took me\na while to detect that the problem was a missing slash in the base url.\nHowever, it would not have solved completely my problem, and for me the best has\nbeen to add the line of code you proposed in the previous email.\n\n\nI am running a Debian testing (wheezy) server, so the distro gitweb files are:\n\n\t/etc/apache2/conf.d/gitweb\n\t/etc/gitweb.conf\n\t/usr/share/gitweb/gitweb.cgi\n\t/usr/share/gitweb/index.cgi -> /usr/share/gitweb/gitweb.cgi\n\t/usr/share/gitweb/static/*\n\nI am using two sets of git repositories, and each of the sets works through a\nparticular gitolite user:\n\n\tuser     home\n\t----------------------\n\tgit      /srv/project\n\tmygit    /srv/mygit\n\nI wanted that different groups of people were able to browse the 'project' repos\n(in fact it is a mirror from the main project server) from\n\thttp://server.example.com/project/ ,\nand the 'mygit' repos from\n\thttp://server.example.com/mygit/ .\nAnd I wanted to keep urls as short and easy as possible, and to avoid\nproliferation of configs as much as possible.\n\nThe setup I came up with was to link\n\n\t/srv/www/project -> /usr/share/gitweb\n\t/srv/www/mygit -> /usr/share/gitweb\n\nand to use the following configuration files:\n\n######### /etc/apache2/conf.d/gitweb ##################\n<Directory /srv/www/project>\n        SetEnv  GITWEB_PROJECTROOT      /srv/git/\n        SetEnv  GITWEB_CONFIG           /etc/gitweb.conf\n        <IfModule mod_authn_file.c>\n                AuthType Basic\n                AuthName \"Project gitweb\"\n                AuthUserFile /srv/htpwd/git-htpasswd\n        </IfModule>\n        Require valid-user\n        Order allow,deny\n        Allow from 123.123.123.123\n        Satisfy Any\n        Options FollowSymLinks +ExecCGI\n        AddHandler cgi-script .cgi\n        RewriteEngine On\n        RewriteBase /project/\n        RewriteCond %{REQUEST_FILENAME} !-f\n        RewriteCond %{REQUEST_FILENAME} !-d\n        RewriteRule ^.* /project/index.cgi/$0 [L,PT]\n</Directory>\n\n<Directory /srv/www/mygit>\n        SetEnv  GITWEB_PROJECTROOT      /srv/mygit/\n        SetEnv  GITWEB_CONFIG           /etc/gitweb.conf\n        <IfModule mod_authn_file.c>\n                AuthType Basic\n                AuthName \"My gitweb\"\n                AuthUserFile /srv/htpwd/mygit-htpasswd\n        </IfModule>\n        Require valid-user\n        Order allow,deny\n        Allow from 213.213.213.213\n        Satisfy Any\n        Options FollowSymLinks +ExecCGI\n        AddHandler cgi-script .cgi\n        RewriteEngine On\n        RewriteBase /mygit/\n        RewriteCond %{REQUEST_FILENAME} !-f\n        RewriteCond %{REQUEST_FILENAME} !-d\n        RewriteRule ^.* /mygit/index.cgi/$0 [L,PT]\n</Directory>\n#######################################################\n\n######### /etc/gitweb.conf ############################\n$projectroot = $ENV{'GITWEB_PROJECTROOT'}.\"repositories\";\n$git_temp = \"/tmp\";\n$projects_list = $ENV{'GITWEB_PROJECTROOT'}.\"projects.list\";\n@diff_opts = ();\n$feature{'pathinfo'}{'default'} = [1];\n$feature{'highlight'}{'default'} = [1];\n$projects_list_description_width = 50;\n#######################################################\n\nProbably there are better ways to implement this, but at least this seems to\nwork, once I have added\n\n\t$base_url .= '/' unless ($base_url =~ m!/$!);\n\nto /etc/gitweb.conf .\n\nGreetings, and thanks again,\n\n\tE.\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.11 (GNU/Linux)\n\niEYEARECAAYFAk+MOEsACgkQY+7weQMem3w4NwCfYHyX+vtap/HvV7/8CTYu42W2\nAbEAoLi2868tD6LGoFdisiplWf9vSdRx\n=RAme\n-----END PGP SIGNATURE-----\n"},{"id":"189518","messageId":"201204171430.52650.jnareb@gmail.com","threadId":"30152","inReplyTo":"4F8C384C.2040109@gmail.com","subject":"Re: Static gitweb content when using pathinfo","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2012-04-17T12:30:52Z","receivedAt":"2012-04-17T12:30:52Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Mon, 16 Apr 2012, José María Escartín Esteban wrote:\n> On 14/04/12 19:19, Jakub Narebski wrote:\n>> On Thu, 5 Apr 2012, Jakub Narebski wrote:\n>>> On Thu, 5 Apr 2012, José María Escartín Esteban wrote:\n\n>>> There might be problem if you configured your web server to serve gitweb\n>>> using it as a handler for subdirectory, so the script name does not need\n>>> to appear in URL, e.g.\n>>>\n>>>   http://localhost/cgi-bin/gitweb\n>>>\n>>> which would require the following base element\n>>>\n>>>   <base href=\"http://localhost/cgi-bin/gitweb/\" />\n>>\n>> [...]\n>>\n> \n> Yes, that was precisely the problem.\n\nNote that you won't have problem with `http://localhost` as base url\n(without any directory), or in more realistic case using virtual host\nrather than virtual directory.  The problem is that without '/' the\npath part of $base_url is stripped of last element.\n\nJust for completeness.\n\n[...]\n> This addition to the man page would of course have been useful, since it took me\n> a while to detect that the problem was a missing slash in the base url.\n> However, it would not have solved completely my problem, and for me the best has\n> been to add the line of code you proposed in the previous email.\n\nSo how about the proposed updated addition at the end of this email?\n\n> I am running a Debian testing (wheezy) server, so the distro gitweb files are:\n> \n> \t/etc/apache2/conf.d/gitweb\n> \t/etc/gitweb.conf\n> \t/usr/share/gitweb/gitweb.cgi\n> \t/usr/share/gitweb/index.cgi -> /usr/share/gitweb/gitweb.cgi\n> \t/usr/share/gitweb/static/*\n> \n> I am using two sets of git repositories, and each of the sets works through a\n> particular gitolite user:\n> \n> \tuser     home\n> \t----------------------\n> \tgit      /srv/project\n> \tmygit    /srv/mygit\n> \n> I wanted that different groups of people were able to browse the 'project' repos\n> (in fact it is a mirror from the main project server) from\n> \thttp://server.example.com/project/ ,\n> and the 'mygit' repos from\n> \thttp://server.example.com/mygit/ .\n> And I wanted to keep urls as short and easy as possible, and to avoid\n> proliferation of configs as much as possible.\n\nI think that is this \"two sets\" that created configuration with a problem.\n \n> The setup I came up with was to link\n> \n> \t/srv/www/project -> /usr/share/gitweb\n> \t/srv/www/mygit -> /usr/share/gitweb\n> \n> and to use the following configuration files:\n> \n> ######### /etc/apache2/conf.d/gitweb ##################\n> <Directory /srv/www/project>\n>         SetEnv  GITWEB_PROJECTROOT      /srv/git/\n>         SetEnv  GITWEB_CONFIG           /etc/gitweb.conf\n[...]\n> #######################################################\n> \n> ######### /etc/gitweb.conf ############################\n> $projectroot = $ENV{'GITWEB_PROJECTROOT'}.\"repositories\";\n> $git_temp = \"/tmp\";\n> $projects_list = $ENV{'GITWEB_PROJECTROOT'}.\"projects.list\";\n> @diff_opts = ();\n> $feature{'pathinfo'}{'default'} = [1];\n> $feature{'highlight'}{'default'} = [1];\n> $projects_list_description_width = 50;\n> #######################################################\n\nA question: why not have\n\n          SetEnv  GITWEB_PROJECTROOT      /srv/git\n\nand use\n\n  $projectroot = \"$ENV{'GITWEB_PROJECTROOT'}/repositories\";\n  $projects_list = \"$ENV{'GITWEB_PROJECTROOT'}/projects.list\";\n \n\nBTW. what is this $git_temp?  Is it modified gitweb, because core one\ndoesn't need to use temporary directory for anything nowadays?\n\nA tip: you can use GITWEB_CONFIG_COMMON for the common part of\nconfiguration and separate GITWEB_CONFIG for per-instance configuration.\nThough I am not sure if it would help in your case.  It requires\nmodern gitweb. though.\n\n> Probably there are better ways to implement this, but at least this seems to\n> work, once I have added\n> \n> \t$base_url .= '/' unless ($base_url =~ m!/$!);\n> \n> to /etc/gitweb.conf .\n\n-- >8 ---------- >8 --\nSubject: [PATCH] gitweb.conf(5): When to set $base_url\n\nAdd a paragraph to description of $base_url variable in gitweb.conf(5)\nmanpage explaining when and why one might need to set it, and how.\n\nBased-on-report-by: José María Escartín Esteban <ripero84@gmail.com>\nSigned-off-by: Jakub Narębski <jnareb@gmail.com>\n---\n Documentation/gitweb.conf.txt |   24 ++++++++++++++++++++++++\n Documentation/gitweb.txt      |    4 ++++\n 2 files changed, 28 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt\nindex 7aba497..4716a0f 100644\n--- a/Documentation/gitweb.conf.txt\n+++ b/Documentation/gitweb.conf.txt\n@@ -559,6 +559,30 @@ $base_url::\n \tPATH_INFO.  Usually gitweb sets its value correctly,\n \tand there is no need to set this variable, e.g. to $my_uri or \"/\".\n \tSee `$per_request_config` if you need to override it anyway.\n++\n+You would need to set this variable when using path_info-based URLs\n+while using gitweb as a directory handler (which means that full path\n+to browse repositories looks like `http://git.example.com/gitweb`\n+rather than looking like `http://git.example.com/gitweb/gitweb.cgi`).\n+You can find yourself in this situation (gitweb as directory handler)\n+when configuring gitweb to use FastCGI interface as shown in\n+\"Webserver configuration\" section on linkgit:gitweb[1] manpage.\n++\n+If static files are served from 'static' subdirectory of directory\n+the gitweb script is handler for, with default URLs of static files\n+(e.g. `$logo` is `static/git-logo.png`), then you would need to ensure\n+that `$base_url` ends with slash to denote that it is directory, to\n+work correctly:\n++\n+----------------------------------------------------------------------\n+$base_url .= '/' unless ($base_url =~ m!/$!);\n+----------------------------------------------------------------------\n++\n+For example if gitweb URL is `http://git.example.com/gitweb`, and\n+static files are available in `http://git.example.com/gitweb/static/`\n+then `$base_url` must end up to be `http://git.example.com/gitweb/`\n+(with trailing slash) for e.g. `static/git-logo.png` relative link\n+to refer to `http://git.example.com/gitweb/static/git-logo.png`.\n \n \n CONFIGURING GITWEB FEATURES\ndiff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt\nindex b394ecc..c3db66a 100644\n--- a/Documentation/gitweb.txt\n+++ b/Documentation/gitweb.txt\n@@ -473,6 +473,10 @@ With that configuration the full path to browse repositories would be:\n \n   http://server/gitweb\n \n+Note that for this configuration `$base_url` must be set as described\n+in linkgit:gitweb.conf[5] for gitweb to correctly serve static files\n+with path_info links.\n+\n As PSGI using plackup\n ~~~~~~~~~~~~~~~~~~~~~\n Gitweb can run as PSGI app (via emulation with *CGI::Emulate::PSGI*(3pm)).\n-- \n1.7.9\n"},{"id":"189938","messageId":"4F964FDA.6030807@gmail.com","threadId":"30152","inReplyTo":"201204171430.52650.jnareb@gmail.com","subject":"Re: Static gitweb content when using pathinfo","fromName":"José María Escartín Esteban","fromEmail":"ripero84@gmail.com","sentAt":"2012-04-24T07:01:46Z","receivedAt":"2012-04-24T07:01:46Z","isPatch":false,"sender":{"key":"ripero84@gmail.com","avatar":"https://gravatar.com/avatar/bcfe92ac2883f73dc13aa100b0cc85092ca55a3c9e441f9a7b4bab1303b5f9fa?d=mp&s=160"},"body":"-----BEGIN PGP SIGNED MESSAGE-----\nHash: SHA1\n\nHello again,\n\nOn 17/04/12 14:30, Jakub Narebski wrote:\n> On Mon, 16 Apr 2012, José María Escartín Esteban wrote:\n>> On 14/04/12 19:19, Jakub Narebski wrote:\n>>> On Thu, 5 Apr 2012, Jakub Narebski wrote:\n>>>> On Thu, 5 Apr 2012, José María Escartín Esteban wrote:\n> \n>>>> There might be problem if you configured your web server to serve\n>>>> gitweb using it as a handler for subdirectory, so the script name\n>>>> does not need to appear in URL, e.g.\n>>>> \n>>>> http://localhost/cgi-bin/gitweb\n>>>> \n>>>> which would require the following base element\n>>>> \n>>>> <base href=\"http://localhost/cgi-bin/gitweb/\" />\n>>> \n>>> [...]\n>>> \n>> \n>> Yes, that was precisely the problem.\n> \n> Note that you won't have problem with `http://localhost` as base url \n> (without any directory), or in more realistic case using virtual host \n> rather than virtual directory.  The problem is that without '/' the path\n> part of $base_url is stripped of last element.\n> \n> Just for completeness.\n> \n\nRight.\n\n> [...]\n>> This addition to the man page would of course have been useful, since it\n>> took me a while to detect that the problem was a missing slash in the\n>> base url. However, it would not have solved completely my problem, and\n>> for me the best has been to add the line of code you proposed in the\n>> previous email.\n> \n> So how about the proposed updated addition at the end of this email?\n> \n\nI think now it's more clear and explicit, and more useful for users not\nfamiliar with Perl, so better.  Thank you!\n\n>> I am running a Debian testing (wheezy) server, so the distro gitweb files\n>> are:\n>> \n>> /etc/apache2/conf.d/gitweb /etc/gitweb.conf /usr/share/gitweb/gitweb.cgi \n>> /usr/share/gitweb/index.cgi -> /usr/share/gitweb/gitweb.cgi \n>> /usr/share/gitweb/static/*\n>> \n>> I am using two sets of git repositories, and each of the sets works\n>> through a particular gitolite user:\n>> \n>> user     home ---------------------- git      /srv/project mygit\n>> /srv/mygit\n>> \n>> I wanted that different groups of people were able to browse the\n>> 'project' repos (in fact it is a mirror from the main project server)\n>> from http://server.example.com/project/ , and the 'mygit' repos from \n>> http://server.example.com/mygit/ . And I wanted to keep urls as short and\n>> easy as possible, and to avoid proliferation of configs as much as\n>> possible.\n> \n> I think that is this \"two sets\" that created configuration with a problem.\n> \n>> The setup I came up with was to link\n>> \n>> /srv/www/project -> /usr/share/gitweb /srv/www/mygit ->\n>> /usr/share/gitweb\n>> \n>> and to use the following configuration files:\n>> \n>> ######### /etc/apache2/conf.d/gitweb ################## <Directory\n>> /srv/www/project> SetEnv  GITWEB_PROJECTROOT      /srv/git/ SetEnv\n>> GITWEB_CONFIG           /etc/gitweb.conf\n> [...]\n>> #######################################################\n>> \n>> ######### /etc/gitweb.conf ############################ $projectroot =\n>> $ENV{'GITWEB_PROJECTROOT'}.\"repositories\"; $git_temp = \"/tmp\"; \n>> $projects_list = $ENV{'GITWEB_PROJECTROOT'}.\"projects.list\"; @diff_opts =\n>> (); $feature{'pathinfo'}{'default'} = [1]; \n>> $feature{'highlight'}{'default'} = [1]; $projects_list_description_width\n>> = 50; #######################################################\n> \n> A question: why not have\n> \n> SetEnv  GITWEB_PROJECTROOT      /srv/git\n> \n> and use\n> \n> $projectroot = \"$ENV{'GITWEB_PROJECTROOT'}/repositories\"; $projects_list =\n> \"$ENV{'GITWEB_PROJECTROOT'}/projects.list\";\n> \n\nAren't both configurations equivalent? (just moving a slash to one side or the\nother of the definitions)\n\n> \n> BTW. what is this $git_temp?  Is it modified gitweb, because core one \n> doesn't need to use temporary directory for anything nowadays?\n> \n\nThat option is enabled by default in all the Debian shipped /etc/gitweb.conf.\n It was like this the first time I installed the package from the Debian\nrepos, and it is still like this in the last version of the package in the\nrepos, gitweb_1.7.10-1_all.deb.  I didn't know it was any sort of modified\ngitweb, the script is in git_1.7.10-1_all.deb (yes, they make a separate\npackage for gitweb but the script is in the git one), and the only differences\nto the v1.7.10 upstream source seem to be installation variables/flags.\n\n> A tip: you can use GITWEB_CONFIG_COMMON for the common part of \n> configuration and separate GITWEB_CONFIG for per-instance configuration. \n> Though I am not sure if it would help in your case.  It requires modern\n> gitweb. though.\n> \n\nI will check that, thanks again.\n\nGreetings,\n\n\tE.\n\n>> Probably there are better ways to implement this, but at least this seems\n>> to work, once I have added\n>> \n>> $base_url .= '/' unless ($base_url =~ m!/$!);\n>> \n>> to /etc/gitweb.conf .\n> \n> -- >8 ---------- >8 -- Subject: [PATCH] gitweb.conf(5): When to set\n> $base_url\n> \n> Add a paragraph to description of $base_url variable in gitweb.conf(5) \n> manpage explaining when and why one might need to set it, and how.\n> \n> Based-on-report-by: José María Escartín Esteban <ripero84@gmail.com> \n> Signed-off-by: Jakub Narębski <jnareb@gmail.com> --- \n> Documentation/gitweb.conf.txt |   24 ++++++++++++++++++++++++ \n> Documentation/gitweb.txt      |    4 ++++ 2 files changed, 28\n> insertions(+), 0 deletions(-)\n> \n> diff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt \n> index 7aba497..4716a0f 100644 --- a/Documentation/gitweb.conf.txt +++\n> b/Documentation/gitweb.conf.txt @@ -559,6 +559,30 @@ $base_url:: PATH_INFO.\n> Usually gitweb sets its value correctly, and there is no need to set this\n> variable, e.g. to $my_uri or \"/\". See `$per_request_config` if you need to\n> override it anyway. ++ +You would need to set this variable when using\n> path_info-based URLs +while using gitweb as a directory handler (which\n> means that full path +to browse repositories looks like\n> `http://git.example.com/gitweb` +rather than looking like\n> `http://git.example.com/gitweb/gitweb.cgi`). +You can find yourself in this\n> situation (gitweb as directory handler) +when configuring gitweb to use\n> FastCGI interface as shown in +\"Webserver configuration\" section on\n> linkgit:gitweb[1] manpage. ++ +If static files are served from 'static'\n> subdirectory of directory +the gitweb script is handler for, with default\n> URLs of static files +(e.g. `$logo` is `static/git-logo.png`), then you\n> would need to ensure +that `$base_url` ends with slash to denote that it is\n> directory, to +work correctly: ++ \n> +---------------------------------------------------------------------- \n> +$base_url .= '/' unless ($base_url =~ m!/$!); \n> +---------------------------------------------------------------------- ++ \n> +For example if gitweb URL is `http://git.example.com/gitweb`, and +static\n> files are available in `http://git.example.com/gitweb/static/` +then\n> `$base_url` must end up to be `http://git.example.com/gitweb/` +(with\n> trailing slash) for e.g. `static/git-logo.png` relative link +to refer to\n> `http://git.example.com/gitweb/static/git-logo.png`.\n> \n> \n> CONFIGURING GITWEB FEATURES diff --git a/Documentation/gitweb.txt\n> b/Documentation/gitweb.txt index b394ecc..c3db66a 100644 ---\n> a/Documentation/gitweb.txt +++ b/Documentation/gitweb.txt @@ -473,6 +473,10\n> @@ With that configuration the full path to browse repositories would be:\n> \n> http://server/gitweb\n> \n> +Note that for this configuration `$base_url` must be set as described +in\n> linkgit:gitweb.conf[5] for gitweb to correctly serve static files +with\n> path_info links. + As PSGI using plackup ~~~~~~~~~~~~~~~~~~~~~ Gitweb can\n> run as PSGI app (via emulation with *CGI::Emulate::PSGI*(3pm)).\n-----BEGIN PGP SIGNATURE-----\nVersion: GnuPG v1.4.12 (GNU/Linux)\n\niEYEARECAAYFAk+WT9YACgkQY+7weQMem3xchQCcCxsIOs7GOcluIb++KKweK76Y\nTRcAnjauwtudLCc2qTwJd5D8FxwI34mC\n=MbaI\n-----END PGP SIGNATURE-----\n"}]}