Proxy Servers
Like most people where they work there is always a proxy server present. Love them or hate them they are here to stay. Recently where I am working we faced a problem. All the HTTP traffic is going thorough the proxy. However there was a specific case where we did not want it to.
The Problem
When we sent a request to a URL lets call it http://example.com (please note that this is an internal address) it would resolve to a load balanced address. For some reason (I'm not a networking guy) the proxy could not connect to it.
The Solution
What I needed to do was the following:
- I edited the /etc/hosts file and added IP_ADDRESS example.com
- I added export no_proxy="example.com" so it does not use the proxy.
conn = Faraday.new(url: 'example.com') do |faraday|
faraday.request :url_encoded
faraday.response :logger
faraday.adapter :excon
end
Call conn.get and everything worked.
As I found it hard to find a solution I thought I would write it down for someone else to find it useful.