我的网站正在使用http
我现在希望它使用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访问,效果很好。
谢谢!
最佳答案
看起来您忘记了新VirtualHost中的WSGI设置部分。
关于django - 添加SSL时Django 1.8 App显示文件夹结构,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34494034/