Forum OpenACS Q&A: Re: how to config for multiple aolserver instances

Collapse
Posted by Brad Duell on
Here's how I got virtual hosting to work with squid and tinydns (this is cleaner and works *much* better for me than reverseproxy via apache).  Oh yeah, and it can work via ssl too.  (forgive me if I leave something out - thanks to Jon Griffin and Cathy Sarisky for helping me get this up and running):

This requires the install of daemontools (which runs services like tinydns), djbdns (which supplies tinydns), and squid (which proxies requests to port 80 to the correct internal IP address)...

Choose an internal ip range you'll want to serve your virtual servers on (in my case, I'll serve up 192.168.1.2 to 192.168.1.x).

Tie those internal IP addresses to eth0 (so when you do an ifconfig you see all of these ip addresses bound to eth0).

Setup djbdns (use http://cr.yp.to/djbdns/run-server.html as a guide) with the following (say my domain is mydomain.com with the external IP address of 66.1.1.1):
    Your external IP address as the dns server.
    Your internal IP addresses with their respective domains.
    You should ultimately have a /service/tinydns/root/data file resembling:
    -----------------------------------------
    .mydomain.com:66.1.1.1:a:259200
    .1.168.192.in-addr.arpa:66.1.1.1:a:259200
    =mydomain.com:192.168.1.2:86400
    +www.mydomain.com:192.168.1.2:86400
    =dev.mydomain.com:192.168.1.3:86400
    =xml.mydomain.com:192.168.1.4:86400
    =mydomain2.com:192.168.1.5:86400
    +www.mydomain2.com:192.168.1.5:86400
    +mail.mydomain2.com:192.168.1.5:86400
    -----------------------------------------
    This has mydomain.com and www.mydomain.com pointing to the instance on 192.168.1.2
    This has dev.mydomain.com pointing to the instance on 192.168.1.3
    This has xml.mydomain.com pointing to the instance on 192.168.1.4
    This has mydomain2.com and www.mydomain2.com and mail.mydomain2.com pointing to the instance on 192.168.1.5

Add "search localdomain" (without quotes) to the top of your /etc/resolv.conf file.

Use dig to check your setup once tinydns is up and running (i.e. "dig xml.mydomain.com" should give me 192.168.1.4).

Setup squid (I found http://squid.visolve.com/white_papers/reverseproxy.htm to be informative):
    I simply changed my squid.conf file to:
    # http_port 3128
    # http_access deny all
    # httpd_accel_port 80
    # httpd_accel_single_host off
    # httpd_accel_uses_host_header off
    To:
    http_port 127.0.0.1:80
    http_access allow all
    httpd_accel_host virtual
    httpd_accel_port 80
    httpd_accel_single_host off
    httpd_accel_uses_host_header on

Startup squid.

Change your respective server instances to run on their correct internal IP addresses and port 80.  And start them up.

Your box should now be serving port 80 to the outside the correct server running on that instance's port 80 on the inside.

This seems like a lot of work up front (and it is), but adding more hosts is a breeze, and this method seems to work all the way around.

Hope this helps.