diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-03-12 20:59:17 +0000 |
---|---|---|
committer | GitLab Release Tools Bot <robert+release-tools@gitlab.com> | 2019-03-13 13:28:59 +0000 |
commit | 2a3472f07c9db87605c143270c4ea7f587a1005b (patch) | |
tree | 92d4d3782bfeae15e81fff810017bacaa287eacb /lib | |
parent | 745fc6773681cd77a732c7b3273c84df2272bd18 (diff) | |
download | gitlab-ce-2a3472f07c9db87605c143270c4ea7f587a1005b.tar.gz |
Merge branch 'sh-revert-rack-request-health-checks' into 'master'
Fix health checks not working behind load balancers
Closes #58573
See merge request gitlab-org/gitlab-ce!26055
(cherry picked from commit ef19ded4b0b5cc3aabb50b3432c8711f23a2742b)
01203e71 Fix health checks not working behind load balancers
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/middleware/basic_health_check.rb | 8 | ||||
-rw-r--r-- | lib/gitlab/request_context.rb | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/gitlab/middleware/basic_health_check.rb b/lib/gitlab/middleware/basic_health_check.rb index acf8c301b8f..84e49805428 100644 --- a/lib/gitlab/middleware/basic_health_check.rb +++ b/lib/gitlab/middleware/basic_health_check.rb @@ -24,7 +24,13 @@ module Gitlab def call(env) return @app.call(env) unless env['PATH_INFO'] == HEALTH_PATH - request = ActionDispatch::Request.new(env) + # We should be using ActionDispatch::Request instead of + # Rack::Request to be consistent with Rails, but due to a Rails + # bug described in + # https://gitlab.com/gitlab-org/gitlab-ce/issues/58573#note_149799010 + # hosts behind a load balancer will only see 127.0.0.1 for the + # load balancer's IP. + request = Rack::Request.new(env) return OK_RESPONSE if client_ip_whitelisted?(request) diff --git a/lib/gitlab/request_context.rb b/lib/gitlab/request_context.rb index d9811e036d3..f6d289476c5 100644 --- a/lib/gitlab/request_context.rb +++ b/lib/gitlab/request_context.rb @@ -13,7 +13,13 @@ module Gitlab end def call(env) - req = ActionDispatch::Request.new(env) + # We should be using ActionDispatch::Request instead of + # Rack::Request to be consistent with Rails, but due to a Rails + # bug described in + # https://gitlab.com/gitlab-org/gitlab-ce/issues/58573#note_149799010 + # hosts behind a load balancer will only see 127.0.0.1 for the + # load balancer's IP. + req = Rack::Request.new(env) Gitlab::SafeRequestStore[:client_ip] = req.ip |