
gitweb を使用して nginx で動作するように gitolite を設定しようとしています。gitweb は問題なく動作し、gitolite が提供するすべてのアクセス制御機能を認識しているにもかかわらず、http 経由でリポジトリ自体にアクセスできないようです。たとえば、リポジトリを取得しようとすると、次のメッセージが表示されます。
user@hostname:$ git fetch origin master Username for 'http://git.<hostname>': <Username> Password for 'http://<Username>@git.<hostname>': remote: An error occurred while reading CGI reply (no response received) fatal: unable to access 'http://git.<hostname>/git/<reponame>.git/': The requested URL returned error: 502
現在の nginx 設定は次のようになります。
server {
listen 127.0.0.1:80;
server_name git.<hostname>;
root /usr/share/gitweb;
# Basic Authentication
auth_basic "Private Git Server";
auth_basic_user_file /srv/etc/.htpasswd;
location ~ /git(/.*) {
root /srv/git/;
client_max_body_size 0;
# fcgiwrap is set up to listen on this host:port
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /srv/git/gitolite-source/src/gitolite-shell;
# export all repositories under GIT_PROJECT_ROOT
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param GIT_PROJECT_ROOT /srv/http/repositories;
fastcgi_param GITOLITE_HTTP_HOME /srv/git;
fastcgi_param PATH_INFO $1;
fastcgi_pass unix:/var/run/fcgiwrap.sock;
}
try_files $uri @gitweb;
location @gitweb {
fastcgi_pass unix:/var/run/fcgiwrap.sock;
fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
fastcgi_param PATH_INFO $uri;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_param GITWEB_CONFIG /srv/git/gitweb/gitweb.conf;
include fastcgi_params;
}
}
Gitolite は /srv/git にインストールされており、すべてのリポジトリ (gitolite 設定ファイルなどを含む) は /srv/http に保存されています (gitolite は http ユーザーで実行されています)。これは設定ミスの問題だと思います。現在の設定で http 経由で git を操作できるようにするにはどうすればいいでしょうか? ちなみに私は Arch を使用しています。
答え1
まあ、解決策はあと1歩のところにあった。GITOLITE_HTTP_HOME
パラメータは、/srv/http;
の代わりに/srv/git;.
以上です。gitweb と git は両方とも完璧に機能し、gitolite.conf で設定された権限を尊重します。