Apache
Jump to navigation
Jump to search
Example Vhost Configurations
Generic http
<VirtualHost *:80> ServerName foo.com ServerAlias *.foo.com DocumentRoot "/www/files/foo" ErrorLog /www/logs/foo.com.error_log CustomLog /www/logs/foo.com.access_log combined </VirtualHost>
Note, I usually put the following in httpd.conf to keep the individual virtualhosts un-cluttered, since all my sites have the parent same doc root:
ServerAdmin me@me.com <Directory "/www/files"> Options FollowSymLinks MultiViews Order allow,deny Allow from all </Directory>
Generic SSL
<VirtualHost 10.0.0.65:443> ServerName secure.foo.com DocumentRoot "/www/files/foo" ErrorLog /www/logs/secure.foo.com.error_log CustomLog /www/logs/secure.foo.com.access_log combined SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite SSLv3:+HIGH:+MEDIUM #Network Solutions is where i get my ssl certs, they require chaining SSLCertificateFile /usr/local/apache2/ssl.certs/STAR.MYTRADERONLINE.COM.crt SSLCertificateChainFile /usr/local/apache2/ssl.certs/STAR.MYTRADERONLINE.COM.NetworkSolutions_CA.crt SSLCertificateKeyFile /usr/local/apache2/conf/ssl.certs/wildcard.mytraderonline.com.key <FilesMatch "\.(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory "/www/files/foo"> SSLOptions +StdEnvVars Options FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade </VirtualHost>
Redirects
http to https
<VirtualHost *:80> ServerName secure.foo.com RewriteEngine On RewriteRule (.*) https://my.cycletrader.com/$1 </VirtualHost>