gitlab + nginx 설치 시 502 bad gateway 일 경우 해결 방안

Programming 2014. 2. 5. 19:16 by touchsoul

336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

Fail To Load Assets Due To Permission Issues

Error: When access GitLab, the login page is broken, images and CSS files are not correctly loaded.

In Nginx error log

2013/08/23 13:52:19 [error] 31035#0: *1 open() "/home/git/gitlab/public/assets/login-logo-20fd89985ad8929292196a39fa51787c.png" failed (13: Permission denied), client: 10.191.131.75, server: devops.company.com, request: "GET /assets/login-logo-20fd89985ad8929292196a39fa51787c.png HTTP/1.1", host: "devops.company.com", referrer: "http://devops.company.com/users/sign_in"
2013/08/23 13:52:22 [error] 31035#0: *1 open() "/home/git/gitlab/public/assets/application-8d0430122c22e07faecdd974cd21a38b.css" failed (13: Permission denied), client: 10.191.131.75, server: devops.company.com, request: "GET /assets/application-8d0430122c22e07faecdd974cd21a38b.css HTTP/1.1", host: "devops.company.com", referrer: "http://devops.company.com/users/sign_in"
2013/08/23 13:52:22 [error] 31035#0: *10 open() "/home/git/gitlab/public/assets/application-7b88a88b92ad70a827dbedb75e5206b1.js" failed (13: Permission denied), client: 10.191.131.75, server: devops.company.com, request: "GET /assets/application-7b88a88b92ad70a827dbedb75e5206b1.js HTTP/1.1", host: "devops.company.com", referrer: "http://devops.company.com/users/sign_in"

Problem: Permission denied when nginx user was trying to open assets (images, CSS files). The nginx user does NOT have access to the assets directory because it is NOT member of the git group.

NOTE: In the installation guide, adding Nginx user to the git group is NOT explicitly mentioned. However, it is well documented in theGitlab Recipes.

Solution:

Recommended

add nginx user to git group and give groups read/execute permission on /home/git

sudo usermod -a -G git nginx
sudo chmod g+rx /home/git/

Alternatively, replace the default nginx user with git and group root in /etc/nginx/nginx.conf

#user             nginx;
user              git root;

Then restart Nginx, the issue should be fixed. See issue 4893 for more information.


Error on first run the homepage return 502 bad gateway (nginx) after 30/60 seconds

Fix First start seems slow so increase the unicorn timeout to something larger, say 200. (Or buy faster hardware)

vim config/unicorn.rb
sudo /etc/init.d/gitlab restart


Nav