| | 289 | * https://lab.mitty.jp/git/ で実際に用いている設定 |
| | 290 | {{{ |
| | 291 | RewriteEngine On |
| | 292 | RewriteCond %{QUERY_STRING} =service=git-receive-pack [OR] |
| | 293 | RewriteCond %{REQUEST_URI} /git-receive-pack$ |
| | 294 | RewriteRule /git/ - [E=AUTHREQUIRED:yes] |
| | 295 | <Location /git> |
| | 296 | SetEnv GITWEB_CONFIG /etc/gitweb/lab.conf |
| | 297 | SetEnv GIT_HTTP_EXPORT_ALL |
| | 298 | SetEnv GIT_PROJECT_ROOT /path/to/projectroot/lab |
| | 299 | Order Deny,Allow |
| | 300 | Deny from env=AUTHREQUIRED |
| | 301 | AuthType Basic |
| | 302 | AuthName "Authentication for lab.mitty.jp" |
| | 303 | AuthUserFile /path/to/htpasswd.file |
| | 304 | Require valid-user |
| | 305 | Satisfy Any |
| | 306 | </Location> |
| | 307 | AliasMatch ^/git/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /path/to/projectroot/lab/$1 |
| | 308 | AliasMatch ^/git/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /path/to/projectroot/lab/$1 |
| | 309 | ScriptAliasMatch \ |
| | 310 | "(?x)^/git/(.*/(HEAD | \ |
| | 311 | info/refs | \ |
| | 312 | objects/info/[^/]+ | \ |
| | 313 | git-(upload|receive)-pack))$" \ |
| | 314 | /usr/lib/git-core/git-http-backend/$1 |
| | 315 | Alias /git /usr/share/gitweb |
| | 316 | <Directory /usr/share/gitweb> |
| | 317 | Options +ExecCGI |
| | 318 | DirectoryIndex gitweb.cgi |
| | 319 | AddHandler cgi-script .cgi |
| | 320 | </Directory> |
| | 321 | }}} |
| | 322 | * gitweb/git-http-backend を一つのURLでアクセス可能にしている |
| | 323 | * git fetchは認証なし、pushは要認証 |
| | 324 | * https://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html でLocationMatchを用いて説明されている方法は古いため動かない |
| | 325 | * man git-http-backend あるいは http://man7.org/linux/man-pages/man1/git-http-backend.1.html などにあるように、mod_rewriteが必要 |
| | 326 | * {{{Order Deny,Allow}}}、{{{Satisfy Any}}}などに注意 |
| | 327 | * /etc/gitweb/lab.conf |
| | 328 | {{{ |
| | 329 | $projectroot = "/var/git/lab"; |
| | 330 | @git_base_url_list = ($cgi->url(-base => 1) . '/git'); |
| | 331 | }}} |
| | 332 | * GITWEB_CONFIGでgitwebインスタンスごとに設定ファイルを指定できる |
| | 333 | * man git-http-backendではgitwebは{{{ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/}}}などとしているが、うまく動かない |
| | 334 | * {{{/git/?p=lab.git}}}となるべきリンクが{{{/git?p=lab.git}}}となってしまう |
| | 335 | * wiki:TipAndDoc/network/httpd#ScriptAlias にあるように、自身のURLが{{{/}}}で終わらない形になるためと思われる |
| | 336 | * Alias + Directoryで対応 |
| | 337 | |