parse_proxy_headers

in files/gitlab-cookbooks/gitlab/libraries/nginx.rb [75:107]


    def parse_proxy_headers(app, ssl, allow_other_schemes = false)
      values_from_gitlab_rb = Gitlab[app]['proxy_set_headers']
      dashed_app = SettingsDSL::Utils.node_attribute_key(app)
      default_from_attributes = Gitlab['node']['gitlab'][dashed_app]['proxy_set_headers'].to_hash

      default_from_attributes['X-Forwarded-Ssl'] = 'on' if ssl

      unless allow_other_schemes
        scheme = ssl ? 'https' : 'http'
        default_from_attributes['X-Forwarded-Proto'] = scheme
      end

      if Gitlab[app]['proxy_protocol']
        default_from_attributes = default_from_attributes.merge({
                                                                  'X-Real-IP' => '$proxy_protocol_addr',
                                                                  'X-Forwarded-For' => '$proxy_protocol_addr'
                                                                })
      end

      if values_from_gitlab_rb
        values_from_gitlab_rb.each do |key, value|
          if value.nil?
            default_attrs = Gitlab['node'].default['gitlab'][dashed_app]['proxy_set_headers']
            default_attrs.delete(key)
          end
        end

        default_from_attributes = default_from_attributes.merge(values_from_gitlab_rb.to_hash)
      end

      Gitlab[app]['proxy_set_headers'] = default_from_attributes
    end