Difference between revisions of "Apache"

From KeegansWiki
Jump to navigation Jump to search
Line 55: Line 55:
 
         ServerName secure.foo.com
 
         ServerName secure.foo.com
 
         RewriteEngine On
 
         RewriteEngine On
         RewriteRule (.*) https://my.cycletrader.com/$1
+
         RewriteRule (.*) https://my.cycletrader.com$1
 
</VirtualHost>
 
</VirtualHost>
 
</pre>
 
</pre>

Revision as of 13:56, 14 April 2011

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/secure.foo.com.crt
        SSLCertificateChainFile /usr/local/apache2/ssl.certs/secure.foo.com.NetworkSolutions_CA.crt
        SSLCertificateKeyFile /usr/local/apache2/conf/ssl.certs/secure.foo.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>