HTTP Proxy problem

J

Joe Mitchell

I'm having trouble getting Proxy to work properly within our corporate
firewall. I've validated the proxy settings. Mozilla is able to reach
the Internet just fine using the specified proxy, but my demo Ruby app
is not.

Also, I noticed that I was not able to reach a site within the firewall
unless I specified the IP address rather than the URL. I've done some
sniffing through the stack using the debugger, and the correct URL
seems to be passed down through it.

Any suggestions as to what configuration settings I should check or
what to watch for in the stack would be welcome.

Here is what I'm running:

require 'net/http'
h =
Net::HTTP::proxy('http://proxy-sd.am.sony.com/proxy/proxy.pac',8080)
#h.start('http://www.pragmaticprogrammer.com') do |http| #doesn't work
h.start(URI.parse('http://www.pragmaticprogrammer.com')) do |http|
response = h.get('/index.htm')
if response.message =="OK"
puts response.body.scan(/<img src="(.*?)"/m).uniq
end
end


[mitchell@localhost tutorials]$ ruby -w t18_HTTP_Network.rb
/usr/local/lib/ruby/1.8/net/protocol.rb:83:in `initialize':
getaddrinfo: Name or service not known (SocketError)
from /usr/local/lib/ruby/1.8/net/protocol.rb:83:in `new'
from /usr/local/lib/ruby/1.8/net/protocol.rb:83:in `connect'
from /usr/local/lib/ruby/1.8/net/protocol.rb:82:in `timeout'
from /usr/local/lib/ruby/1.8/timeout.rb:55:in `timeout'
from /usr/local/lib/ruby/1.8/net/protocol.rb:82:in `connect'
from /usr/local/lib/ruby/1.8/net/protocol.rb:64:in `initialize'
from /usr/local/lib/ruby/1.8/net/http.rb:430:in `open'
from /usr/local/lib/ruby/1.8/net/http.rb:430:in `do_start'
from /usr/local/lib/ruby/1.8/net/http.rb:419:in `start'
from /usr/local/lib/ruby/1.8/net/http.rb:324:in `start'
from t18_HTTP_Network.rb:9
 
A

Assaph Mehr

Joe said:
I'm having trouble getting Proxy to work properly within our corporate
firewall. I've validated the proxy settings. Mozilla is able to reach
the Internet just fine using the specified proxy, but my demo Ruby app
is not.

Is it perhaps an MS Proxy? If your net-admins set it to use NTLM
authentication then it would explain the problem (Ruby's net/http proxy
only handles Basic authentication).
Also, I noticed that I was not able to reach a site within the firewall
unless I specified the IP address rather than the URL. I've done some
sniffing through the stack using the debugger, and the correct URL
seems to be passed down through it.

Proxies are usually set to look outwards only, and the browser has a
setting to bypass the proxy for certain addresses/namespaces. I don't
think there's a global way to set it. In your script you'll likely need
to set the same values, check if the requested site is within those
values and then decide whetehr to use Net::HTTP::proxy or just
Net::HTTP.

HTH,
Assaph
 
M

Minero Aoki

Hi,

In mail "HTTP Proxy problem"
Joe Mitchell said:
I'm having trouble getting Proxy to work properly within our corporate
firewall. I've validated the proxy settings. Mozilla is able to reach
the Internet just fine using the specified proxy, but my demo Ruby app
is not.
Here is what I'm running:

require 'net/http'
h =
Net::HTTP::proxy('http://proxy-sd.am.sony.com/proxy/proxy.pac',8080)

remove "http://". Net::HTTP::proxy requires hostname, not URI.

Regards,
Minero Aoki
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top