I'm making a simple website to host git repositories, much like github. I'm using Gittornado to handle git Smart HTTP requests, and it works perfectly locally; I can clone, push, pull, etc... But when I put it behind Nginx, git commands stop working, giving no errors except: "fatal: The remote end hung up unexpectedly"

I know that it's Nginx that's causing the trouble because if I open the port that tornado is running on and try my git commands through that (i.e. "git pull \http://mysite.com:8000/myrepository master" instead of "git pull \http://mysite.com/myrepository master" [backslashes added because Server Fault says I have too many links]) everything works as expected. The Nginx access and error logs don't seem to say anything interesting, so I'm reasonably sure that it has something to do with the way Nginx is compressing or chunking the requests/responses, causing git to think there's been an unexpected hangup, but I'm not sure what to do to fix it, since this is my first time with Nginx.

My Nginx configuration file is basically a clone of the on found here; I've tried commenting out various likely-seeming options to see if they were causing the problem, but none of them fixed it so I assume there's some default behavior I need to suppress, I'm just not sure which.

Any thoughts on how to fix this? Since it works not through Nginx, I'm considering just redirecting git requests to the tornado port itself, but this feels like a hack rather than a clean solution...

  • Would have gottan back to you faster if you had opened an issue on github or sent me an email ;) – mensi Mar 24 '13 at 15:05

Usually the issues lie with the chunked transfer encoding git uses. This is the same with gittornado and the CGI backend shipped with git.

See this serverfault answer suggesting setting proxy_buffering off; in the location block.

  • This was probably part of it but by itself didn't fix the issue. I had actually just switched to haproxy since that worked without issue, but I finally got it to work with nginx by adding "proxy_http_version 1.1;" to my nginx.conf file. Apparently nginx was gzipping, which tornado only supports with http 1.1? – Josh Buell Apr 27 '13 at 19:16
  • As far as I remember, I had to implement the gzip handling myself... The big difference with http 1.1 is the chunked transfer which is not available in 1.0 – mensi Apr 27 '13 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.