I have an Apache server running a number of named virtual hosts that I want to use SSL with. Apache doesn't support named virtual hosts in the SSL configuration file, because of the way the protocols work. I need to route requests by hostname using SSL. How can I do that?
Apache cannot support named virtual hosts in SSL host configuration files, because it cannot see the hostname header when the SSL request is being processed. You can use a directory-level configuration file, typically called .htaccess, to redirect the request, because the host name information is available at that later point in the processing.
To do this, include the line
AllowOverride Options FileInfo AuthConfig
in the general configuration section of the apache httpd.conf server configuration file. This allows you to use the Apache URL rewriting engine from a directory-level configuration file.
In the directory defined as DocumentRoot in the <VirtualHost_default:443> section of the Apache SSL configuration file, create an .htaccess file containing three lines:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} ^.*$
RewriteRule ^(.*)$ http://%{HTTP_HOST}:80/$1 [P]
This will send the decrypted SSL request to the host named in the http headers by proxy so that your users see only the https URLs.
Depending on how your sites are named, users may see security warnings that your SSL certificate does not match the hostname.
| Use this form to start a public discussion with other Linux World users on this article. Log In | Register for an account (Why you should) |
Note: Register to have your user name appear; otherwise your comment will show up as "Anonymous."
*Anonymous comments will only appear once they are approved by the moderator.
• Dell puts Linux and Atom in Vostro PCs
• Mozilla names best Firefox 3 add-ons
• Torvalds: Fed up with the 'security circus'
• Dell Latitude ON - big win for Linux
• Open source advocates hail appeals court ruling
LinuxWorld Conference and Expo San Francisco, August 4-7, 2008.
Linux Plumbers Conference Portland, OR, Sept. 16-19, 2008.
FreedomHEC Santa Monica, November 8-9, 2008.