http_client_proxy.rb 648 B

12345678910111213141516171819202122
  1. Rails.application.configure do
  2. config.x.http_client_proxy = {}
  3. if ENV['http_proxy'].present?
  4. proxy = URI.parse(ENV['http_proxy'])
  5. raise "Unsupported proxy type: #{proxy.scheme}" unless %w(http https).include? proxy.scheme
  6. raise "No proxy host" unless proxy.host
  7. host = proxy.host
  8. host = host[1...-1] if host[0] == '[' # for IPv6 address
  9. config.x.http_client_proxy[:proxy] = {
  10. proxy_address: host,
  11. proxy_port: proxy.port,
  12. proxy_username: proxy.user,
  13. proxy_password: proxy.password,
  14. }.compact
  15. end
  16. config.x.access_to_hidden_service = ENV['ALLOW_ACCESS_TO_HIDDEN_SERVICE'] == 'true'
  17. end