Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to be sure that for some URL of my website, SSL will be use. I saw a lot of answer already on SO.

http://stackoverflow.com/questions/724968/force-redirect-to-ssl-for-all-pages-apart-from-one

So I think I will use mod_rewrite.

My question is more about how to configure the Virtual Host to run my Django Application over HTTP and over HTTPS without problems. I am using WSGI.

Is it a problem to just duplicate the configuration over *:443 and over *:80 ? How should I do to have the best configuration ?

Thank you.

Rémy

share|improve this question
    
Maybe this is related : effbot.org/zone/django-multihost.htm –  Natim Oct 10 '09 at 16:00
    
Answers on StackOverflow at 'stackoverflow.com/questions/1548210/…;. –  Graham Dumpleton Oct 11 '09 at 2:21

2 Answers 2

up vote 2 down vote accepted

you can use a decorator on your views to make them only avail from ssl.

@secure_required
@login_required
def edit_member(request, slug):
    ...

http://www.redrobotstudios.com/blog/2009/02/18/securing-django-with-ssl/

share|improve this answer

It is fine to copy over the configuration for *:443, here's how I did it on my server:

<VirtualHost *:80>
        ServerName www.mydomain.tld
        ServerAlias mydomain.tld

        DocumentRoot /path/to/www
        <Directory /path/to/www>
                AllowOverride All
                Order allow,deny
                allow from all
                Options -MultiViews
        </Directory>

</VirtualHost>

<VirtualHost *:443>
        ServerName www.mydomain.tld
        ServerAlias mydomain.tld

        DocumentRoot /path/to/www
        <Directory /path/to/www>
                AllowOverride All
                Order allow,deny
                allow from all
                Options -MultiViews
        </Directory>

        SSLEngine On
        SSLCertificateFile /etc/ssl/private/mydomain.crt

</VirtualHost>

Be sure to activate SSL on the *:443 virtual host (SSLEngine), and have your certificate set-up also (SSLCertificateFile).

You will also need to activate the ssl module for Apache2, type as root:

a2enmod ssl
share|improve this answer
    
With Django it is not that simple. But thanks anyway, the answer is on the StackOverflow post overthere. –  Natim Jun 26 '10 at 11:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.