Social Bookmarking

del.icio.us Digg Furl Blinklist Reddit Technorati Yahoo My Web Newsvine Socializer Ma.gnolia Stumble Upon Google Bookmarks RawSugar Squidoo Spurl BlinkBits Netvouz Rojo Blogmarks Co.mments Scuttle Feed Me Links Yigg Mr.Wong

Sandy Dunlop

A 27 year old software consultant living in Glasgow.

IRC: jaavaaguru on irc.freenode.net

Email: sandy@sorn.net

Adverts

Current Projects

Find Sandy online

Miscellanea

tagsociety

Dynamic virtual hosting with proxying

If you read the Apache documentation, dynamic virtual hosting is simple, and having Apache act as a gateway or proxy to other servers is straightforward too. Dynamic virtual hosting is useful if you want to have lots of websites hosted on one machine - it allows you to create a rule that generates a document root based on the domain name ni the URL.

Now, if you want to set up a machine so that it acts as a gateway to some machines, and everything else is a dynamic virtual host, that's more complicated. I figured out how to do it and here's what I added to my apache.conf:

NameVirtualHost *:80

<VirtualHost *:80>
UseCanonicalName Off
<Directory />
Options FollowSymLinks ExecCGI Multiviews Includes
AllowOverride All
</Directory>
VirtualDocumentRoot /export/home/websites/%0/web
</VirtualHost>

That sets up the default virtual host which will deal with the dynamic virtual hosting using a VirtualDocumentRoot. The %0 in the document root is replaced by the domain name used in the HTTP request. For example http://www.sorn.net/index.php goes to /export/home/websites/www.sorn.net/web

<VirtualHost *:80>
ServerName www.macmini.wireless.sorn.net
ProxyPass / http://wireless.sorn.net:84/
</VirtualHost>

The above section of the apache.conf file sets up proxying for one particular domain name to another machine on the same network as my Apache server. All requests for www.macmini.wireless.sorn.net are passed onto wireless.sorn.net for processing.
tags: web
No comments

Post a comment

What is twenty added to four ?:
Name: URL:
Comment: