sandy's blog


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 goes to /export/home/websites/ <VirtualHost *:80> ServerName ProxyPass / </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 are passed onto for processing.


Post a Comment

Subscribe to Post Comments [Atom]

Links to this post:

Create a Link

<< Home