502 error upstream url wrong with non-bundled web-server
Created by: jk2K
/etc/gitlab/gitlab.rb
external_url 'http://git.mydomain.com'
web_server['external_users'] = ['www']
nginx['enable'] = false
nginx conf
upstream gitlab {
server unix:/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket fail_timeout=0;
}
server {
listen *:80;
server_name git.mydomain.com;
server_tokens off; ## Don't show the nginx version number, a security best practice
root /opt/gitlab/embedded/service/gitlab-rails/public;
## Increase this if you want to upload large attachments
## Or if you want to accept large git objects over http
client_max_body_size 250m;
## Individual nginx logs for this GitLab vhost
access_log /data/logs/nginx/git.mydomain/gitlab_access.log;
error_log /data/logs/nginx/git.mydomain/gitlab_error.log;
location / {
## Serve static files from defined root folder.
## @gitlab is a named location for the upstream fallback, see below.
try_files $uri $uri/index.html $uri.html @gitlab;
}
location /uploads/ {
## If you use HTTPS make sure you disable gzip compression
## to be safe against BREACH attack.
## https://github.com/gitlabhq/gitlabhq/issues/694
## Some requests take more than 30 seconds.
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;
}
## If a file, which is not found in the root folder is requested,
## then the proxy passes the request to the upsteam (gitlab unicorn).
location @gitlab {
## If you use HTTPS make sure you disable gzip compression
## to be safe against BREACH attack.
## https://github.com/gitlabhq/gitlabhq/issues/694
## Some requests take more than 30 seconds.
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;
}
## Enable gzip compression as per rails guide:
## http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
## WARNING: If you are using relative urls remove the block below
## See config/application.rb under "Relative url support" for the list of
## other files that need to be changed for relative url support
location ~ ^/(assets)/ {
root /opt/gitlab/embedded/service/gitlab-rails/public;
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
error_page 502 /502.html;
}
sudo gitlab-ctl status
run: logrotate: (pid 23554) 3239s; run: log: (pid 12342) 133136s
run: postgresql: (pid 12912) 32039s; run: log: (pid 12197) 133167s
run: redis: (pid 12920) 32039s; run: log: (pid 12108) 133173s
run: sidekiq: (pid 12926) 32038s; run: log: (pid 12302) 133144s
run: unicorn: (pid 12929) 32038s; run: log: (pid 12263) 133146s
visit git.mydomain.com
, the browser displays 502 error
nginx error log
2015/07/24 23:46:01 [error] 24412#0: *147233 connect() failed (111: Connection refused) while connecting to upstream, client: {myip}, server: git.quxiangtou.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8888/", host: "git.mydomain.com"
external_url
had been set 'http://127.0.0.1:8888'
gitlab-ctl reconfigure
has been run, nginx new configuration already loaded
gitlab version: gitlab-ce_7.13.1-ce.0_amd64.deb
os version: Ubuntu 14.04 LTS