来自Nginx的502 Bad Gateway用于大型GitLab fork

我正在通过Nginx运行GitLab 6.0.0并且可以分叉小型存储库,但是当我尝试分叉大型存储库(2GB)时,我会在大约一分钟后看到“502 Bad Gateway”页面.

/var/log/nginx/gitlab_error.log显示:

2013/08/29 12:21:33 [error] 25098#0: *221 upstream prematurely closed connection while reading response header from upstream, 
  client: 12.34.56.78, 
  server: myserver, 
  request: "POST /mygroup/myproject/fork HTTP/1.1", 
  upstream: "http://unix:/home/git/gitlab/tmp/sockets/gitlab.socket:/mygroup/myproject/fork", 
  host: "myserver", 
  referrer: "http://myserver/mygroup/myproject/fork"
最佳答案
Issue 1527表明内存问题(和memory requirement in mentioned in the doc).

它也可能是因为初始超时:

I found this error would also occur because the unicorn workers would sometimes take 33 seconds to start and they’re configured to timeout after 30 seconds.

你可以修改unicorn配置文件/home/git/gitlab/config/unicorn.rb:

timeout 300

在您的NGiNX配置中,您还可以添加:

proxy_connect_timeout 300;
proxy_read_timeout 300;

如果你的NGiNX上有/ etc / nginx / fastcgi_params文件,你可以添加:

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 156 16k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_intercept_errors on;
fastcgi_max_temp_file_size 0

fastcgi_pass            unix:/tmp/fpm.sock;

请注意,在502之后,在进行上述修复之后,最好在再次尝试访问gitlab之前清除浏览器缓存.

转载注明原文:来自Nginx的502 Bad Gateway用于大型GitLab fork - 代码日志