1

From my understanding of git, the http/https interface is simple. You have two commands - push and fetch.

Based on a wireshark trace the fetch URL appears to be in this format:

/git/#path-to-repo#/info/refs?service=git-upload-pack 

The push URLs appear to be in these formats:

/git/#path-to-repo#/info/refs?service=git-receive-pack /git/#path-to-repo#/git-receive-pack 

I would like to setup nginx configuration so that pushes go to one git backend and fetches come from a different one (the git mirror using gitblit federation).

So I set up a nginx configuration like this:

proxy_cache_bypass $arg_preview; location ~ (.*)git-receive-pack { proxy_pass http://#push-ip#:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto http; proxy_set_header X-Forwarded-Port 80; } location / { proxy_pass http://#pull-ip#:8080/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto http; proxy_set_header X-Forwarded-Port 80; } 

Whilst this configuration correctly sends /git/#path-to-repo#/git-receive-pack format URLs to the push IP, the /git/#path-to-repo#/info/refs?service=git-receive-pack format URLs still go to the pull IP.

How can I get URLs of the form /git/#path-to-repo#/info/refs?service=git-receive-pack to go to the #push-ip# as well?

1 Answer 1

2

OK, this was easier than I thought. Just added another section between the first and second location block:

location ~ (.*)\/refs { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto http; proxy_set_header X-Forwarded-Port 80; if ($arg_service = "git-receive-pack") { proxy_pass http://#push-ip#:8080; break; } proxy_pass http://#pull-ip#:8080; } 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.