Joyent

 

VirtualHosts

First some basic things:

Where to find the VirtualHost file

The out-of-the-box location for the file is /opt/csw/apache2/etc/virtualhosts (blastwave template) or /opt/local/etc/httpd/ (pkgsrc template).

If you want to change the location, then look in your /opt/csw/apache2/etc/httpd.conf (blastwave template) or /opt/local/etc/httpd/httpd.conf (pkgsrc template) file for the following lines to change the path:

# And here are the virtualhost files
Include /opt/csw/apache2/etc/virtualhosts/*.conf

Multiple URLs pointing to same site

Site to come up as http://www.example.com, http://example.com and http://blog.example.com

ServerName www.example.com
ServerAlias example.com
ServerAlias blog.example.com

If you only want a single url to work then only define a value for ServerName.

Set the order of default pages served

DirectoryIndex index.html dispatch.fcgi

Setting the htdocs dir

Where is the public dir:

DocumentRoot /home/domains/www.example.com/current/public

rewrite

Enable rewrite:

RewriteEngine* On

Don’t serve up the SVN stuff:

RewriteRule ^(.*/)?\.svn/ - [F,L]

Log files

define the error log file:

ErrorLog /opt/csw/apache2/var/log/blog.example.com.error

define the location of the custom file note “common” is defined in httpd.conf which is the format for the file:

CustomLog /opt/csw/apache2/var/log/blog.example.com common

The complete VirtualHost Entry

putting it all together 001-example.com.conf file: I use mongrel cluster with 5 balancing.

<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAlias blog.example.com
DirectoryIndex index.html dispatch.fcgi
DocumentRoot /home/domains/www.example.com/current/public
RewriteEngine On
RewriteRule ^(.*/)?\.svn/ - [F,L]
ProxyPass /images !
ProxyPass /stylesheets !
ProxyPass /javascripts !
ProxyPass / balancer://blog/
ProxyPassReverse / balancer://blog
ProxyPreserveHost On
ErrorLog /opt/csw/apache2/var/log/blog.example.com.error
CustomLog /opt/csw/apache2/var/log/blog.example.com common
<Proxy balancer://blog>
BalancerMember http://127.0.0.1:8010
BalancerMember http://127.0.0.1:8011
BalancerMember http://127.0.0.1:8012
BalancerMember http://127.0.0.1:8013
BalancerMember http://127.0.0.1:8014
</Proxy>
</VirtualHost>
 
accelerators/kb/apache/virtualhosts.txt · Last modified: 2008/04/05 21:13 by lderezinski
 
Recent changes RSS feed Creative Commons License Driven by DokuWiki