Setting the proxy server for RoR application


#1

Hi ~

I written a RoR application that need to feed the web content using
web service or make a get or post request to another server. However
the RoR application server is located behind the proxy, so that if my
web broswer need to get a homepage, it need to set the proxy host and
port in the browser before to use. But for my RoR application, how can
it know that their have a proxy server, so that the application can
correctly get the web content?

I did research on some forums, and i always said that use the
following code that also appear in the ruby documentation

require ‘net/http’

proxy_addr = 'your.proxy.host'
proxy_port = 8080
        :
Net::HTTP::Proxy(proxy_addr, proxy_port).start('www.example.com')

{|http|
# always connect to your.proxy.addr:8080
:
}

Is there have another general way (i mean the proxy setting can apply
to whole RoR application without changing the code) to set the proxy
setting for RoR application? Can it be set in the environment file?

Thank ~
Patrick