Skip to content

Next

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Support
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
GitLab
GitLab
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
    • Cycle Analytics
    • Insights
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 23,618
    • Issues 23,618
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 834
    • Merge Requests 834
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Security & Compliance
    • Security & Compliance
    • Dependency List
  • Packages
    • Packages
    • Container Registry
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • GitLab.org
  • GitLabGitLab
  • Issues
  • #3137

Closed
Open
Opened Aug 10, 2017 by Nick Thomas@nick.thomas💃
  • Report abuse
  • New issue
Report abuse New issue

Support the http_proxy environment variable for elasticsearch

Summary

Per https://gitlab.com/gitlab-org/gitlab-ee/issues/3125#note_37127998

Our Ruby elasticsearch client uses Faraday, which doesn't automatically pick up http_proxy or https_proxy envvars.

Steps to reproduce

$ http_proxy=http://127.0.0.1:8888 bin/rails c
Loading development environment (Rails 4.2.8)
[1] pry(main)> c = Gitlab::Elastic::Client.build(ApplicationSetting.current.elasticsearch_config)
[2] pry(main)> c.transport.connections.first.connection.proxy
nil

What is the current bug behavior?

Requests do not go via specified proxy

What is the expected correct behavior?

Requests should go via proxy

Possible fixes

https://gitlab.com/gitlab-org/gitlab-ee/blob/master/lib/gitlab/elastic/client.rb#L12

This method needs to add transport_options: { proxy: ENV['http_proxy'] } to base_config if the variable is set, per http://www.rubydoc.info/gems/elasticsearch-transport/Elasticsearch/Transport/Client#initialize-instance_method

I'm not sure about https_proxy, especially given we can specify a mix of http and https URLs to the elasticsearch client.

This doesn't seem to be the full story though. I did this and made some requests through a non-existent proxy server and got results back, instead of ECONNREFUSED:

[1] pry(main)> c = ::Elasticsearch::Client.new(url: 'http://localhost:9200', transport_options: { proxy: 'http://localhost:666' })
[2] pry(main)> c.transport.connections.first.connection.proxy
=> #<struct Faraday::ProxyOptions uri=#<URI::HTTP http://localhost:666>, user=nil, password=nil>
[3] pry(main)> c.get(index: 'gitlab-development', id: 1)
=> {"_index"=>"gitlab-development",
 "_type"=>"snippet",
# ...
}

Related issues

  • Discussion
  • Designs
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
13
Labels
Create [DEPRECATED] Enterprise Edition P4 S3 auto updated awaiting feedback backend bug default-priority default-severity devops::enablement elasticsearch group::search
Assign labels
  • View project labels
Reference: gitlab-org/gitlab#3137