2014-01-13 26 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') 

這就是現在,如果其他一些放慢參數需要調整將嘗試添加它。

相關問題