# Your domain name Define SERVER_NAME git.example.com Define SSL_CERT /etc/ssl/certs/${SERVER_NAME}.pem Define SSL_KEY /etc/ssl/private/${SERVER_NAME}.key # Path to your project root. Make sure it matches what's in cgitrc/gitweb.conf Define GIT_PROJECT_ROOT /srv/gitroot # Comment this out if you want to use the per-repository git-daemon-export-ok files SetEnv GIT_HTTP_EXPORT_ALL # Which features to use Define USE_GITWEB #Define USE_CGIT Define USE_SMART_HTTP Define USE_DUMB_HTTP # Where do the applications live (these are Debian's defaults) Define GIT_LIBDIR /usr/lib/git-core Define GITWEB_SHAREDIR /usr/share/gitweb Define CGIT_LIBDIR /usr/lib/cgit Define CGIT_SHAREDIR /usr/share/cgit # HTTP to HTTPS redirect ServerName ${SERVER_NAME} ErrorLog ${APACHE_LOG_DIR}/${SERVER_NAME}/error.log CustomLog ${APACHE_LOG_DIR}/${SERVER_NAME}/access.log combined RedirectMatch (.*) https://${SERVER_NAME}$1 ServerName ${SERVER_NAME} SSLEngine on SSLCertificateFile ${SSL_CERT} SSLCertificateKeyFile ${SSL_KEY} SSLProtocol ALL -SSLv2 -SSLv3 SSLHonorCipherOrder on SSLCipherSuite EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH SSLCompression Off ErrorLog ${APACHE_LOG_DIR}/${SERVER_NAME}/error.log CustomLog ${APACHE_LOG_DIR}/${SERVER_NAME}/access.log combined # Authentication AuthType Basic AuthName "${SERVER_NAME} git access" # You'll probably want to customize this, using ldap or pam authentication. AuthBasicProvider file AuthUserFile /etc/git-users Require valid-user # Gitweb Error "Both gitweb and cgit are enabled. Please enable only one." DocumentRoot ${GITWEB_SHAREDIR} Options +FollowSymLinks +ExecCGI AddHandler cgi-script .cgi DirectoryIndex gitweb.cgi Require all granted RewriteEngine on RewriteRule ^/(.*\.git(|(/(?!(HEAD|info|objects|refs|git-(upload|receive)-pack)).*)))$ \ /gitweb.cgi%{REQUEST_URI} [L,PT] # CGit Options +FollowSymLinks +ExecCGI AddHandler cgi-script .cgi Require all granted Require all granted RewriteEngine on RewriteRule ^/(.*\.git(|(/(?!(HEAD|info|objects|refs|git-(upload|receive)-pack)).*)))?$ \ ${CGIT_LIBDIR}/cgit.cgi/$1 Alias /cgit-css "${CGIT_SHAREDIR}" # HTTP transports Require all granted SetEnv GIT_PROJECT_ROOT ${GIT_PROJECT_ROOT} ScriptAliasMatch "^/(.*\.git/(HEAD|info/refs))$" \ ${GIT_LIBDIR}/git-http-backend/$1 ScriptAliasMatch "^/(.*\.git/git-(upload|receive)-pack)$" \ ${GIT_LIBDIR}/git-http-backend/$1 Require all granted AliasMatch "^/(.*\.git/(HEAD|info/refs))$" \ ${GIT_PROJECT_ROOT}/$1 AliasMatch "^/(.*\.git/objects/(info/[^/]+|[0-9a-f]{2}/[0-9a-f]{38}|pack/pack-[0-9a-f]{40}\.(pack|idx)))" \ ${GIT_PROJECT_ROOT}/$1