2015-12-28 71 views
3

我的網站正在處理httpDjango 1.8應用程序顯示添加SSL時文件夾strucutre

我現在想讓它使用SSl證書。我已經生成的密鑰並設置虛擬主機:

<VirtualHost *:80> 
     WSGIDaemonProcess pms python-path=/home/ubuntu/myapp/myapp:/home/ubuntu/myapp/env/lib/python3.4$ 
     WSGIProcessGroup myapp 
     WSGIScriptAlias//home/ubuntu/myapp/myapp/myapp/wsgi.py 

     <Directory /home/ubuntu/myapp/myapp/myapp> 
      <Files wsgi.py> 
       Require all granted 
      </Files> 
      Options Indexes FollowSymLinks MultiViews 
      AllowOverride All 
      Order allow,deny 
      Allow from all 
     </Directory> 

     ServerAdmin [email protected] 
</VirtualHost> 

<VirtualHost *:443> 
    SSLEngine On 
    SSLCertificateFile /etc/apache2/ssl/ca.crt 
    SSLCertificateKeyFile /etc/apache2/ssl/ca.key 

    ServerName leanhotelsystem.com 
    ServerAlias *.leanhotelsystem.com 
    DocumentRoot /home/ubuntu/myapp/myapp/myapp 

    <Directory /home/ubuntu/myapp/myapp/myapp> 
     <Files wsgi.py> 
      Require all granted 
     </Files> 

     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Order allow,deny 
     allow from all 
    </Directory> 

    ServerAdmin [email protected] 

    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 

</VirtualHost> 

我也wsgi.py設置:

os.environ['HTTPS'] = "on" 

,並在settings.py:

WSGI_APPLICATION = 'myapp.wsgi.application' 
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') 

的問題是,當我使用https訪問url時,它顯示我的文件夾結構,而不是呈現主頁。 如果我通過http訪問它工作正常。

謝謝!

回答

0

看起來你忘了你的新VirtualHost中的WSGI設置部分。

+0

工作,謝謝!我以爲我只需要在其中一臺主機上設置它。對於任何可能需要它的人,我複製了'WSGIProcessGroup'和'WSGIScriptAlias'設置,但不是'WSGIDaemonProcess'(因爲據我所知,你不能讓2守護進程運行) – JesusAlvSoto

相關問題