This is a quick and dirty config guide to setup git-http-backend
with uwsgi
from supervisord
on nginx
. I did this on Fedora 20
so on a different distro some paths will likely be different.
I've also ignored security in this post as I have ssl termination handled elsewhere. This will send your password in the clear if you don't have ssl setup correctly! Don't forget to setup git permissions as well. This config allows any authorized user (somebody who can login) to push.
Toofishes.net was very helpful.
This will setup your git repos under http://example.com/git/
. The git repos physically live at /srv/git
.
Your nginx.conf
should look something like this, either including git.conf
or having the contents of git.conf directly in the server section.
# /etc/nginx/nginx.conf
...
server {
server_name example.com;
...
include apps/*.conf;
...
}
# /etc/nginx/apps/git.conf
location ~ /git(/.*) {
alias /srv/git;
try_files $uri @git;
}
location @git {
auth_basic "git";
auth_basic_user_file /srv/git/gitusers;
include uwsgi_params;
# export all repositories under GIT_PROJECT_ROOT
uwsgi_param GIT_HTTP_EXPORT_ALL "";
uwsgi_param GIT_PROJECT_ROOT /srv/git;
uwsgi_param PATH_INFO $1;
# required for pusing to repo
uwsgi_param REMOTE_USER $remote_user;
uwsgi_modifier1 9;
uwsgi_pass 127.0.0.1:8021;
}
Use supervisord to start the uwsgi process.
# /etc/supervisord.d/git.conf
[program:git]
command=/sbin/uwsgi --ini /srv/git/git.ini
directory=/srv/git
autostart=true
autorestart=true
stopwaitsecs=2
user=apache
And finally, use uwsgi to start git-http-backend.
# /srv/git/git.ini
[uwsgi]
socket = 127.0.0.1:8021
plugin = cgi
cgi = /usr/libexec/git-core/git-http-backend
chdir = %d
post-buffering = 8192
# start up to 4 but try to stay at 1
processes = 4
cheaper = 1
# lots more customizations possible
Create /srv/git/gitusers
with htpasswd -c /srv/git/gitusers <username>
Hope that helps.