Django | Apache | Deploy website behind SSL
- by planet260
So here are my requirements.
I have a website built in Django. I deployed it on Apache Ubuntu. Before there was no SSL involved so the deployment was pretty simple. But now the requirements are changed. Now I have to take a few actions like signup and login behind SSL and present the admin panel and other normally via HTTP. By following the this tutorial I have set-up Apache and SSL and generated certificates for SSL communication. But I am not sure how to proceed, ie. how to serve only a few of my actions through SSL. Below is my configuration. The normal actions are working fine but I don't know how to configure SSL calls.
WSGIScriptAlias / /home/ubuntu/myproject/src/myproject/wsgi.py
WSGIPythonPath /home/ubuntu/myproject/src
<VirtualHost *:80>
ServerName mydomain.com
<Directory /home/ubuntu/myproject/src/myproject>
<Files wsgi.py>
order deny,allow
Allow from all
</Files>
</Directory>
Alias /static/admin/ "/home/ubuntu/myproject/src/static/admin/"
<Directory "/home/ubuntu/myproject/src/static/admin/">
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>
<Location "/login">
RewriteEngine on
RewriteRule /admin(.*)$ https://mydomain.com/login$1 [L,R=301]
</Location>
</VirtualHost>
<VirtualHost *:443>
ServerName mydomain.com
SSLEngine on
SSLOptions +StrictRequire
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<Directory /home/ubuntu/myproject/src/myproject>
<Files wsgi.py>
order deny,allow
Allow from all
</Files>
</Directory>
Alias /static/admin/ "/home/ubuntu/myproject/src/static/admin/"
<Directory "/home/ubuntu/myproject/src/static/admin/">
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>
</VirtualHost>
Can you please help me out on how to achieve this? What am I doing wrong? I have read a lot of tutorials but honestly I am not really good at configurations. Any help is appreciated.