From: "José María Escartín Esteban" <ripero84@gmail.com>
To: Jakub Narebski <jnareb@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Static gitweb content when using pathinfo
Date: Mon, 16 Apr 2012 17:18:36 +0200 [thread overview]
Message-ID: <4F8C384C.2040109@gmail.com> (raw)
In-Reply-To: <201204141919.19285.jnareb@gmail.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Thank you for your detailed answers, and sorry for the delay in my reply.
On 14/04/12 19:19, Jakub Narebski wrote:
> On Thu, 5 Apr 2012, Jakub Narebski wrote:
>> On Thu, 5 Apr 2012, José María Escartín Esteban wrote:
>>> Hi,
>>>
>>> I'm running gitweb in a server.example.com/gitweb/ scenario. If I don't enable
>>> pathinfo everything works fine, but when I enable pathinfo the static content
>>> stops showing up in the browser.
>>>
>>> I'm not an HTML or perl expert, but I think that this may be due to a missing
>>> slash in the construction of the base tag: Using the upstream script I am getting
>>>
>>> <base href="http://server.example.com/gitweb" />
>>>
>>> and no static content. Once I tune the script to add a final slash to the url
>>>
>>> <base href="http://server.example.com/gitweb/" />
>>>
>>> the static content shows up again.
>>
>> How do you deploy gitweb, what is your web server configuration, and
>> what is the URL of main gitweb page (using placeholders like 'example.com'
>> or 'foo')?
>
> Ping?
>
> [...]
>
I'll describe the setup at the end of my email, but you already provided the
solution!
>> There might be problem if you configured your web server to serve gitweb
>> using it as a handler for subdirectory, so the script name does not need
>> to appear in URL, e.g.
>>
>> http://localhost/cgi-bin/gitweb
>>
>> which would require the following base element
>>
>> <base href="http://localhost/cgi-bin/gitweb/" />
>
> [...]
>
Yes, that was precisely the problem.
>>> Once I tune the script to add a final slash to the url
>>>
>>> <base href="http://server.example.com/gitweb/" />
>>>
>>> the static content shows up again.
>>
>> By "tune the script" do you mean editing gitweb.cgi, or adding setting
>> $base_url to gitweb configuration file, see gitweb.conf(5):
>>
>> $base_url
>> Base URL for relative URLs in pages generated by gitweb, (e.g.
>> $logo, $favicon, @stylesheets if they are relative URLs), needed and
>> used <base href="$base_url"> only for URLs with nonempty PATH_INFO.
>> Usually gitweb sets its value correctly, and there is no need to set
>> this variable, e.g. to $my_uri or "/". See $per_request_config if
>> you need to override it anyway.
>>
>> You can e.g. put
>>
>> $base_url .= '/' unless ($base_url =~ m!/$!);
>>
>> in the gitweb configuration file to ensure that it ends with '/', whatever
>> it is.
>
I was editing manually the gitweb.cgi script to add (always!) the slash. Your
solution is of course better, and completely solves my problem.
> By the way, would the following proposed addition to gitweb.conf(5)
> manpage would help your situation?
>
> -------- >8 ---------- >8 ---------
> Subject: [PATCH/RFC] gitweb.conf(5): When to set $base_url
>
> Add a paragraph to description of $base_url variable in gitweb.conf(5)
> manpage explaining when and why one might need to set it.
>
> Based-on-report-by: José María Escartín Esteban <ripero84@gmail.com>
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> ---
> Documentation/gitweb.conf.txt | 14 ++++++++++++++
> 1 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/Documentation/gitweb.conf.txt b/Documentation/gitweb.conf.txt
> index 7aba497..a2a6ddf 100644
> --- a/Documentation/gitweb.conf.txt
> +++ b/Documentation/gitweb.conf.txt
> @@ -559,6 +559,20 @@ $base_url::
> PATH_INFO. Usually gitweb sets its value correctly,
> and there is no need to set this variable, e.g. to $my_uri or "/".
> See `$per_request_config` if you need to override it anyway.
> ++
> +You would need to set this variable when using gitweb as a directory
> +handler and using path_info-based URLs. For example if your web
> +server is set up in such way that full path to browse repositories is
> +`http://git.example.com/gitweb` and static files are served from
> +'/gitweb/static' directory with default values (e.g. `$logo` is
> +`static/git-logo.png`), then you would need to set `$base_url` to
> +(for example):
> ++
> +----------------------------------------------------------------------
> +our $base_url = "http://git.example.com/gitweb/";
> +----------------------------------------------------------------------
> ++
> +The trailing slash is required!
>
>
> CONFIGURING GITWEB FEATURES
This addition to the man page would of course have been useful, since it took me
a while to detect that the problem was a missing slash in the base url.
However, it would not have solved completely my problem, and for me the best has
been to add the line of code you proposed in the previous email.
I am running a Debian testing (wheezy) server, so the distro gitweb files are:
/etc/apache2/conf.d/gitweb
/etc/gitweb.conf
/usr/share/gitweb/gitweb.cgi
/usr/share/gitweb/index.cgi -> /usr/share/gitweb/gitweb.cgi
/usr/share/gitweb/static/*
I am using two sets of git repositories, and each of the sets works through a
particular gitolite user:
user home
----------------------
git /srv/project
mygit /srv/mygit
I wanted that different groups of people were able to browse the 'project' repos
(in fact it is a mirror from the main project server) from
http://server.example.com/project/ ,
and the 'mygit' repos from
http://server.example.com/mygit/ .
And I wanted to keep urls as short and easy as possible, and to avoid
proliferation of configs as much as possible.
The setup I came up with was to link
/srv/www/project -> /usr/share/gitweb
/srv/www/mygit -> /usr/share/gitweb
and to use the following configuration files:
######### /etc/apache2/conf.d/gitweb ##################
<Directory /srv/www/project>
SetEnv GITWEB_PROJECTROOT /srv/git/
SetEnv GITWEB_CONFIG /etc/gitweb.conf
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "Project gitweb"
AuthUserFile /srv/htpwd/git-htpasswd
</IfModule>
Require valid-user
Order allow,deny
Allow from 123.123.123.123
Satisfy Any
Options FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /project/index.cgi/$0 [L,PT]
</Directory>
<Directory /srv/www/mygit>
SetEnv GITWEB_PROJECTROOT /srv/mygit/
SetEnv GITWEB_CONFIG /etc/gitweb.conf
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "My gitweb"
AuthUserFile /srv/htpwd/mygit-htpasswd
</IfModule>
Require valid-user
Order allow,deny
Allow from 213.213.213.213
Satisfy Any
Options FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
RewriteEngine On
RewriteBase /mygit/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* /mygit/index.cgi/$0 [L,PT]
</Directory>
#######################################################
######### /etc/gitweb.conf ############################
$projectroot = $ENV{'GITWEB_PROJECTROOT'}."repositories";
$git_temp = "/tmp";
$projects_list = $ENV{'GITWEB_PROJECTROOT'}."projects.list";
@diff_opts = ();
$feature{'pathinfo'}{'default'} = [1];
$feature{'highlight'}{'default'} = [1];
$projects_list_description_width = 50;
#######################################################
Probably there are better ways to implement this, but at least this seems to
work, once I have added
$base_url .= '/' unless ($base_url =~ m!/$!);
to /etc/gitweb.conf .
Greetings, and thanks again,
E.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
iEYEARECAAYFAk+MOEsACgkQY+7weQMem3w4NwCfYHyX+vtap/HvV7/8CTYu42W2
AbEAoLi2868tD6LGoFdisiplWf9vSdRx
=RAme
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2012-04-16 15:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-05 13:54 Static gitweb content when using pathinfo José María Escartín Esteban
2012-04-05 21:14 ` Jakub Narebski
2012-04-14 17:19 ` Jakub Narebski
2012-04-16 15:18 ` José María Escartín Esteban [this message]
2012-04-17 12:30 ` Jakub Narebski
2012-04-24 7:01 ` José María Escartín Esteban
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4F8C384C.2040109@gmail.com \
--to=ripero84@gmail.com \
--cc=git@vger.kernel.org \
--cc=jnareb@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).