Fix fpeople git https clone

Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
This commit is contained in:
Patrick Uiterwijk 2015-07-09 23:05:33 +00:00
parent 2ca1f29c58
commit 1dcd73d7ba

View file

@ -58,7 +58,12 @@ NameVirtualHost *:80
<Directory "/home/fedora/*/public_html">
AllowOverride FileInfo AuthConfig Limit Indexes
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
IndexOptions NameWidth=* FancyIndexing
#IndexOptions NameWidth=* FancyIndexing
Require all granted
Require method GET POST OPTIONS
</Directory>
<Directory "/home/fedora/*/public_git*">
Require all granted
Require method GET POST OPTIONS
</Directory>
@ -145,157 +150,37 @@ NameVirtualHost *:80
RewriteRule ^repos\.fedorapeople\.org/(.*) /project/repos/$1 [L]
RewriteRule ^([a-z0-9-]+)\.fedorapeople\.org/(.*) /home/fedora/$1/public_html/$2 [L]
# Use cgit and redirect (some) old gitweb-caching things
RewriteRule ^/cgit-data/(.*)$ /cgit-data/$1 [L,PT]
RewriteRule ^/cgit/(.*)$ /cgit/$1 [L,PT]
# Begin http git clone
# First, deny write access
RewriteCond %{QUERY_STRING} service=git-receive-pack [OR]
RewriteCond %{REQUEST_URI} /git-receive-pack$
RewriteRule ^/git/ - [E=AUTHREQUIRED:yes]
<Location /git>
<RequireAll>
Require not env AUTHREQUIRED
Require all granted
</RequireAll>
Options -Indexes +ExecCGI
</Location>
# blob
RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob/(.+)/(.+):/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=blob;h=(.+);hb=(.+);f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/%5?id=%3;id2=%4 [R,L,NE]
# Next up, determine which user owns this repo
SetEnvIf Request_URI ^/git/([a-zA-Z0-9]*)/.* GIT_PROJECT_ROOT=/home/fedora/$1/public_git
Header set X-GitProject "%{GIT_PROJECT_ROOT}e"
RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob/(.+):/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=blob;hb=(.+);f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/%4?id=%3 [R,L,NE]
# Let's serve objects and packs directly from apache, very performant!
AliasMatch ^/git/([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\.git(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /home/fedora/$1/public_git/$2.git/$3
AliasMatch ^/git/([a-zA-Z0-9]*)/([a-zA-Z0-9]*)\.git(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /home/fedora/$1/public_git/$2.git/$3
RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+);hb=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/%3?id=%4;id2=%5 [R,L,NE]
RewriteCond %{query_string} p=(.+)(\.git);a=blob;f=(.+);h=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/%3?id=%4 [R,L,NE]
# tree
RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+)/(.+):/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+);f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/%5?id=%4?h=%3 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+):/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+);f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/%4?id=%3 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+)/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=tree;h=(.+);hb=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/?id=%4 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=tree;hb=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/?id=%3 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/tree [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=tree
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tree/? [R,L,NE]
# commitdiff
RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+)/(.+):/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=blobdiff;h=(.+);hp=(.+);hb=(.+);f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/diff/%6?id2=%4;id=%3;id3=%5 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+)/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+);hp=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/diff/?id=%4;id2=%3 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/commitdiff/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=commitdiff;h=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/diff/?id=%3 [R,L,NE]
# commit
RewriteCond %{REQUEST_URI} /(.+)(\.git)/commit/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=commit;h=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/commit/?id=%3 [R,L,NE]
# summary
RewriteCond %{REQUEST_URI} /(.+)(\.git)/summary [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=summary
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/? [R,L,NE]
# shortlog
RewriteCond %{REQUEST_URI} /(.+)(\.git)/shortlog/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=shortlog;h=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/?id=%3 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/shortlog [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=shortlog
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/? [R,L,NE]
# log
RewriteCond %{REQUEST_URI} /(.+)(\.git)/log/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=log;h=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/?id=%3 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/log [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=log
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log? [R,L,NE]
# history
RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+)/(.+):/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+);f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/%5?id=%4 [R,L,NE]
RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+);hb=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/%3?id=%4;id2=%5 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/%4?id=%3 [R,L,NE]
RewriteCond %{query_string} p=(.+)(\.git);a=history;f=(.+);h=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/%3?id=%4 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+)/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=history;h=(.+);hb=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/?id=%4 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+):/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+);f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/%4?id=%3 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/history/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=history;hb=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/log/?id=%3 [R,L,NE]
# tag
RewriteCond %{REQUEST_URI} /(.+)(\.git)/tag/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=tag;h=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/tag/?id=%3 [R,L,NE]
# blob_plain
RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob_plain/(.+):/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;h=(.+);f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/plain/%4?id=%3 [R,L,NE]
RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+);hb=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/plain/%3?id2=%4 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/blob_plain/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=blob_plain;f=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/plain/%3 [R,L,NE]
# rss|atom
RewriteCond %{REQUEST_URI} /(.+)(\.git)/(rss|atom)/refs/heads/(.+) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom);h=refsheads/(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/atom?h=%4 [R,L,NE]
RewriteCond %{REQUEST_URI} /(.+)(\.git)/(rss|atom) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=(rss|atom)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/atom? [R,L,NE]
# snapshot
RewriteCond %{REQUEST_URI} /(.+)(\.git)/snapshot/(.+)(\.tar\.gz|\.tar\.bz2) [OR]
RewriteCond %{query_string} p=(.+)(\.git);a=snapshot;h=(.+);sf=(.+)
RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/snapshot/%3.tar.gz [R,L,NE]
# Fail safes incase nothing above matches, try at least to put the person in the project
#RewriteCond %{REQUEST_URI} /([^/]+)\.git.* [OR]
#RewriteCond %{query_string} p=(.+)\.git.*
#RewriteRule ^/.*$ https://fedorapeople.org/cgit/%1.git/? [R,L,NE]
# Or else in the root of cgit
RewriteRule ^/git/(.+)\.git$ /cgit/$1.git [L,PT]
RewriteRule ^/git/(.*)/$ /cgit/$1.git [L,PT]
RewriteRule ^/git/([^/]*)$ /cgit/$1.git [L,PT]
RewriteRule ^/gitweb /cgit/ [L,PT]
# for cgit clone repos
RewriteRule ^/gitrepos/(.*)/public_git/(.*)$ /~$1/git/$2 [L,PT]
# And now for the magic, let's run the git cgi script
ScriptAliasMatch \
"(?x)^/git/([a-zA-Z0-9]*)/(.*/(HEAD | \
info/refs | \
objects/(info/[^/]+ | \
[0-9a-f]{2}/[0-9a-f]{38} | \
pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
git-(upload|receive)-pack))$" \
/usr/libexec/git-core/git-http-backend/$2
# End http git clone
<Directory /srv/people/site/userdefs>
Options IncludesNoExec
@ -308,6 +193,18 @@ NameVirtualHost *:80
IndexOptions +XHTML +SuppressRules +SuppressHTMLPreamble
ServerSignature Off
AddOutputFilter INCLUDES .html
#SetEnvIf Request_URI "(?x)^/git/([^/]*)(.*)$" \
# GIT_PROJECT_ROOT=/home/fedora/$1/public_git
# this takes care of user directories
#ScriptAliasMatch \
# "(?x)^/git/([^/]*)(/.*/(HEAD | \
# info/refs | \
# objects/(info/[^/]+ | \
# [0-9a-f]{2}/[0-9a-f]{38} | \
# pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
# git-(upload|receive)-pack))$" \
# /usr/libexec/git-core/git-http-backend/$2
</VirtualHost>
LoadModule deflate_module modules/mod_deflate.so