2014-01-13 22 views
0

我意识到有这么多的链接讨论这个话题,但到目前为止,没有什么能为我工作。我只想清楚如何为我的项目启用SSL加密。如何使用Bitnami为django应用程序启用SSL?

我的要求:应用程序的所有页面都需要使用“HTTPS”而不是“HTTP”。

我已经安装了Bitnami djangostack-1.4.5-0,现在我正在开发我的localhost端口81,所以如果我可以测试重定向,它也会有很大的帮助。

我已经有一个虚拟的证书我同它的键 “myapp.key” C中的以下文件夹中创建 “myapp.crt”:\ BitNami \ djangostack-1.4.5-0 \ Apache2的\的conf

之后,我读到的所有链接都混淆了我应该改变的地方。请帮忙!!并且清楚变化的下落。

myapp folder structure: 
django.wsgi 
manage.py 
MY_APP (folder) 
    |_ settings.py 
    |_ wsgi.py 
    |_ urls.py 
    |_ _init_.py 
    |_ apps (folder) 
    |_ static (folder) 
    |_ templates (folder) 

回答

0

我想通了一个人,并认为它可能有助于未来的人。

1. Go to httpd.conf located in [BitNami_Installation]\djangostack-1.4.5-0\apache2\conf: 
make sure the following is without # in front of it 

LoadModule rewrite_module modules/mod_rewrite.so 
LoadModule ssl_module modules/mod_ssl.so 


<IfModule ssl_module> 
Include conf/extra/httpd-ssl.conf 
SSLRandomSeed startup builtin 
SSLRandomSeed connect builtin 
</IfModule> 

RewriteEngine On 
RewriteCond %{HTTPS} !=on 
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L] 

2. Go to httpd-ssl.conf located in [BitNami_Installation]\djangostack-1.4.5-0\apache2\conf\extra 
make sure the following is there 
SSLCertificateFile "C:/BitNami/djangostack-1.4.5-0/apache2/conf/myapp.crt" 
SSLCertificateKeyFile "C:/BitNami/djangostack-1.4.5-0/apache2/conf/myapp.key" 

注:证书和密钥是自创建

3. In settings.py 
SESSION_COOKIE_SECURE= True 
CSRF_COOKIE_SECURE=True 
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') 

这就是现在,如果其他一些放慢参数需要调整将尝试添加它。

相关问题