Forum OpenACS Q&A: Sitewide redirects, DNS and Moving a Site

We are planning to move our site from one server to another in different facilities.... This is something that I am sure is fresh in the minds of OpenACS leaders 😊 Of course, now I can plan ahead...

SO we set up the new system on the new server with the most recent data backup. How do we redirect ALL pages to the new site from the old server so that for example:

www.openacs.org/bboard/bboard/q-and-a.tcl? topic_id=11&topic=OpenACS
gets redirected to the same URL with vars on the new machine... Until the DNS propagates throughout the world....

Yes, I could put an ns_returnredirect in *EVERY* index.tcl whatever but there must be an easier way to get AOLSERVER to just forward all requests to www.openacs.org to the new server.

Thank you
-Bob

Collapse
Posted by Pascal Scheffers on
If your bandwith allows it, just set up a proxy server on the old IP. Apache will do this for you just fine. This is also what I do for virtual openacs hosting (The AOLServers are listening on 127.0.0.1, obviously). Works very well. Add to your apache config (server or virual host section):
<virtualhost *>
   servername virtualhost.com
   proxypass  / http://127.0.0.1:8000/
   proxypassreverse  / http://127.0.0.1:8000/
</virtualhost>
and in your nsd.tcl nssock section:
ns_param location "http://virtualhost.com"
Otherwise redirects won't work.
Collapse
Posted by Todd Gillespie on
Use a filter.  There's actually an example on exactly this in "Philip & Alex's":

ns_register_proc GET / martigny_redirect

proc martigny_redirect {} {

    append url_on_swissnet "http://www-swiss.ai.mit.edu" [ns_conn url]

    ns_returnredirect $url_on_swissnet

}

Collapse
Posted by Bob OConnor on

Todd's solution for sitewide redirect was

Use a filter....:

ns_register_proc GET / martigny_redirect 

proc martigny_redirect {} { 
append url_on_swissnet "http://www-swiss.ai.mit.edu" [ns_conn url] 
ns_returnredirect $url_on_swissnet 
} 

So, My question is where does the ns_register_proc... go to make the redirect work?
I tried putting the first line above in .../parameters/nsatgn.tcl and got

Fatal: config: script error: invalid command
 name "ns_register_proc" while executing...

AND
Can I assume that the proc itself goes into
.../tcl/ad-defs.tcl.preload ?

Thank you.... I look forward to your answers as I need to implement this in production in 14 hours!

-Bob

Collapse
Posted by Robert Ezman on
If you look into the your main tcl startup file you'll find something like:
ns_section ns/server/$servername/tcl
ns_param library /web/$servername/tcl

The directory specified is where AOLServer sources tcl files. So in essence all the files in that directory are run at startup. (And any procedures defined are loaded)
Actually you almost got it right. What you should do is take the above script with the definition of the proc and the register_proc. Put it into a file (by any name with a tcl extension) in that directory. .../tcl/ should be fine. And give it a whirl.
Collapse
Posted by Bob OConnor on

Thank you Robert... It works just as you suggested.

I first put it in the ad_defs.tcl.preload but this didn't work.

I'd like to understand what the preload file does. I have used this file to store the mods for headers and footers and my own table templating system which DOES work. -Bob