tags:

views:

48

answers:

1

I have a basic Squid server setup and I am trying to use Ruby's Net::HTTP::Proxy class to send a POST of form data to a specified HTTP endpoint.

I assumed I could do the following:

  Net::HTTP::Proxy(my_host, my_port).start(url.host) do |h|
    req = Net::HTTP::Post.new(url.path)
    req.form_data = { "xml" => xml }
    h.request(req)
  end

But, alas, proxy vs. non-proxied Net::HTTP classes don't seem to use the proxy IP Address. my remote service responds telling me that it received a request from the wrong IP address, ie: not the proxy. I am looking for a specific way to write the procedure, so that I can successfully send a form post via a proxy. Help? :)

A: 

Hah, turns out that is the right way to do it, my issue was actually with Squid and the API I was pushing to. Interesting tip related to this problem, if you are proxying with Squid proxy server, you probably want to add this server config option:

header_access X-Forwarded-For deny all

This will make sure that the proxy completely ignores any relation to the caller's IP address as far as the HTTP endpoint is concerned.

Derek P.