summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-07-19 18:17:14 +0100
committerGitHub <noreply@github.com>2016-07-19 18:17:14 +0100
commit143edc9f2911737c091c8c87a052ff2f02c05719 (patch)
tree13fd0268225502fb8da4e235b9869ca70db598c3 /lib
parent080959ccd4e9ffb075f74486a010e0310ac54a9f (diff)
parente96011262a7290d53492656302e557aee66d6c56 (diff)
downloadchef-zero-143edc9f2911737c091c8c87a052ff2f02c05719.tar.gz
Merge pull request #109 from schrodinger/proxy-aware
Make ChefZero aware of load balancers
Diffstat (limited to 'lib')
-rw-r--r--lib/chef_zero/rest_request.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/chef_zero/rest_request.rb b/lib/chef_zero/rest_request.rb
index f18ce4d..c12ea31 100644
--- a/lib/chef_zero/rest_request.rb
+++ b/lib/chef_zero/rest_request.rb
@@ -14,7 +14,13 @@ module ChefZero
attr_accessor :rest_base_prefix
def base_uri
- @base_uri ||= "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}#{env['SCRIPT_NAME']}"
+ # Load balancer awareness
+ if env['HTTP_X_FORWARDED_PROTO']
+ scheme = env['HTTP_X_FORWARDED_PROTO']
+ else
+ scheme = env['rack.url_scheme']
+ end
+ @base_uri ||= "#{scheme}://#{env['HTTP_HOST']}#{env['SCRIPT_NAME']}"
end
def base_uri=(value)