【发布时间】:2016-04-02 07:59:41
【问题描述】:
我的网站正在使用 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 support@myapp.com
</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 support@myapp.com
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 访问它工作正常。
谢谢!
【问题讨论】: