0

Is it technically possible to setup multiple Django sites using a single SSL certificate on a single IP address with Apache?

Below is an excerpt from my SSL config:

Alias /media/ x:/home/djang-apps/myapp
WSGIScriptAlias / x:/home/djang-apps/myapp/apache/django.wsgi

<Directory x:/home/djang-apps/>
   Order allow,deny
   Allow from all
</Directory>

One of the issues I've come up against is since I only have a single IP address I have only 1 virtual host therefore how can I reference the varius media folders that contain the css/images/js etc for each Django website as well as the WSGIScriptAlias for each site?

I currently have a wild card certificate for *.foo.com

So I would like to be able to add several sites in this fashion:

website1.foo.com website2.foo.com website3.foo.com

Imran Azad
  • 145
  • 5

1 Answers1

1

You'll need to configure a NameVirtualHost directive, and configure a VirtualHost for each different domain.

For example:

NameVirtualHost *:443

<VirtualHost *:443>
    ServerName app1.foo.com
    ServerAlias www.app1.foo.com
    SSLEngine On
    SSLCertificateFile x:/path/to/cert.pem
    SSLCertificateKeyFile x:/path/to/cert.key
    # Any other basic config, logging, etc..
    DocumentRoot x:/home/djang-apps/app1
    # Any other document mapping; that Alias directive, WSGIScriptAlias, etc
</VirtualHost>

<VirtualHost *:443>
    ServerName app2.foo.com
    ServerAlias www.app2.foo.com
    SSLEngine On
    SSLCertificateFile x:/path/to/cert.pem
    SSLCertificateKeyFile x:/path/to/cert.key
    # Any other basic config, logging, etc..
    DocumentRoot x:/home/djang-apps/app2
    # Any other document mapping; that Alias directive, WSGIScriptAlias, etc
</VirtualHost>

Apache may do some whining during startup about Server Name Indication, which you can safely ignore since you're using a wildcard certificate (just make sure that the SSL directives in each vhost all point to the wildcard cert).

Shane Madden
  • 114,520
  • 13
  • 181
  • 251
  • many thanks, I had managed to get it to work before you answered my question, however Apache was complaining so I thought I was doing something wrong, but now I know why and I can ignore it thanks to you! – Imran Azad Jan 18 '12 at 10:47