502 Bad Gateway
Created by: MrKeiKun
Information:
I just migrated from apache to nginx. now I'm getting "502 Bad Gateway" Problem. I already run some tests via [root@server1 ~]# sudo -u nginx cat /home/git/gitlab/tmp/socket/gitlab.socket
and the result is cat: /home/git/gitlab/tmp/socket/gitlab.socket: Permission denied
/etc/nginx/nginx.conf
user nginx;
worker_processes 4;
/etc/nginx/conf.d/gitlab.conf
upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket fail_timeout=0;
}
server {
listen 0.0.0.0:80;
server_name git.mydomain.com;
server_tokens off;
root /home/git/gitlab/public;
client_max_body_size 20m;
access_log /var/log/nginx/gitlab_access.log;
error_log /var/log/nginx/gitlab_error.log;
location / {
try_files $uri $uri/index.html $uri.html @gitlab;
}
location @gitlab {
gzip off;
proxy_read_timeout 300;
proxy_connect_timeout 300;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://gitlab;
}
location ~ ^/(assets)/ {
root /home/git/gitlab/public;
gzip_static on;
expires max;
add_header Cache-Control public;
}
error_page 502 /502.html;
}
Logs:
2014/12/24 07:46:53 [crit] 22036#0: *45 connect() to unix:/home/git/gitlab/tmp/sockets/gitlab.socket failed (13: Permission denied) while connecting to upstream, client: 49.150.185.187, server: git.mydomain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/home/git/gitlab/tmp/sockets/gitlab.socket:/502.html", host: "git.mydomain.com"