Forum OpenACS Q&A: Making connections from behind proxy server...

Good Morning All,

In my e-mail at various times of the day, I receive the following message from OpenACS:

Could not get contents of "http://info.webcrawler.com/mak/projects/robots/active/all.txt" I also occasionally recieve a longer message. This is really amazing since my installation of sendmail on Redhat 7.1 is capable of finding the e-mail relay server and getting it's messages through the cc:Mail gateway with no configuration changes by me. (I have no idea were the e-mail relay server is, it could be in Wash. D.C. or Oklahoma City).

Back on topic: How do I tell OpenACS to make it's connections to the outside world through a proxy server (ie...someserverproxy.generic.com:8080) rather than as a direct connection.

Thanks,
There used to be a post on the subject and I was going to point you to it but can't find it.

The most useful part of that post is the following chunk of code. (I wish I could find the post so I could give credit to the person who wrote the code)

proc ns_httpget_proxy { url } {  
       # used to httpget when aolserver is on a proxy client
       # expects url including http://
       # for some reason this doesn't work with HTTP/1.1
       # I hardcoded my proxy server and port because
       # continually calling global was a pain
       # replace xxx.xxx.xxx.xxx with your proxy server
       # replace yyyy with its port
       #
       # headers are written to $headers, body to $page
       set file_ids [ns_sockopen xxx.xxx.xxx.xxx 80]
       set read_id [lindex $file_ids 0]
       set write_id [lindex $file_ids 1]

       puts $write_id "GET $url HTTP/1.0

"
       flush $write_id
       while {[set line [string trim [gets $read_id]]] != ""} {
       lappend headers $line
       }

       set page [read $read_id]
       close $read_id
       close $write_id

       return $page

} 


I just put this into the aolsrv/modules/tcl directory in the http.tcl file and went through the acs code modifying it to use this rather then the ns_httpget. Though I suppose you could make ns_httpget call ns_httpget_proxy.

Now this was a while ago and quite possibly a native to aolserver function for this was added. Or alternatively possibly acs itself has been modified to be proxy server smart.

My memory is a bit fuzzy regarding this but I don't know for certain if that request for the above text file has some trick to it. That is it may not call ns_httpget directly. In which case it would need to be modified to use it. (I think I just disabled the web crawler bit of code. My web server is behind a firewall and will never be crawled anyway.)

Also sending mail and getting a web page use two seperate protocols and firewals may treat them differently. So the administrator of your firewall may have set it up so you can send mail no problem but requires you to web surf/httpget through the proxy.

Hope this helps.