Multiple Sites with One SSL Certificate :: Blog
Multiple Sites with One SSL Certificate
(posted at 2010-01-20 20:38:05 UTC)
There's two ways of doing this that I use; one is fairly clean:
- Get a wildcard certificate (*.example.com)
- Put all of your sites as subdomains (eg foo.example.com, bar.example.com)
While it "just works", it restricts your choice of domains; an alternative solution, which isn't really suitable for your users, but fine if you just want secure access to an admin panel (your blog, PhpBB, etc) on several different domains, you can hack something together with Apache, mod_proxy, mod_rewrite, and some cookies:
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Thu, 01 Jan 1970 00:00:00 +0000"
RewriteEngine on
RewriteRule ^unset$ https://example.com/ [L,R=301,CO=site:example.com:example.com]
# foo.example.com
RewriteRule ^foo$ https://example.com/ [L,R=301,CO=site:foo:example.com]
RewriteCond %{HTTP_COOKIE} site=foo
RewriteRule ^(.*)$ http://foo.example.com/$1 [L,P]
# bar.example.com
RewriteRule ^bar$ https://example.com/ [L,R=301,CO=site:bar:example.com]
RewriteCond %{HTTP_COOKIE} site=bar
RewriteRule ^(.*)$ http://bar.example.com/$1 [L,P]
If you install the above as ".htaccess" in the root of https://example.com, then https://example.com/foo will make https://example.com/ act as a proxy for http://foo.example.com, https://example.com/bar will make https://example.com/ act as a proxy for http://bar.example.com, and https://example.com/unset will make it display whatever it normally displays.
I hope someone finds this useful.
Comments
Re: Multiple Sites with One SSL Certificate
Posted at 2010-01-20 21:31:37 UTC by "Anonymous"
I like SNI (http://wiki.apache.org/httpd/NameBasedSSLVHostsWithSNI) if you don't have to worry about backwards compatibility with older browsers :)
Re: Multiple Sites with One SSL Certificate
Posted at 2010-01-20 21:55:01 UTC by "Fred"
The problem with both that and wildcard certificates is that it's somewhat more expensive :)
Re: Multiple Sites with One SSL Certificate
Posted at 2010-01-21 09:50:30 UTC by "Rich Moore"
The better way to do this is to buy a certificate for all the domains using SubjectAltNames see http://www.es.net/pub/esnet-doc/SubjectAltName.doc
Re: Multiple Sites with One SSL Certificate
Posted at 2010-01-21 22:52:02 UTC by "Fred"
SubjectAltNames also generally are charged for, and require a new certificate every time the list of domains changes.
New Comment
My Blog ▶ 2010 ▶ January ▶ 20 ▶ Multiple Sites with One SSL Certificate