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

Nic*_*ion 4 git nginx gitlab git-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"
Run Code Online (Sandbox Code Playgroud)

Von*_*onC 7

问题1527 表明存在内存问题(以及文档中提到的内存要求).

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

我发现这个错误也会发生,因为独角兽工人有时需要33秒才能启动,并且他们被配置为在30秒后超时.

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

timeout 300
Run Code Online (Sandbox Code Playgroud)

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

proxy_connect_timeout 300;
proxy_read_timeout 300;
Run Code Online (Sandbox Code Playgroud)

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

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;
Run Code Online (Sandbox Code Playgroud)

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