sandy's blog

2/14/2005

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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



Links to this post:

Create a Link

<< Home