子域的 https 调用正在获取 apache django 部署中主域的 htps 页面

子域的 https 调用正在获取 apache django 部署中主域的 htps 页面

当我打电话时https://new.sample.com,我得到页面https://sample.comhttp://new.sample.com获取正确的页面

sample.com 配置文件

<VirtualHost xx.xx.xx.xx:80>

ServerName sample.com

WSGIScriptAlias / /path/to/my/project/sample.wsgi

</VirtualHost>


<VirtualHost xx.xx.xx.xx:443>

ServerName www.sample.com 

SSLEngine ON
SSLCertificateFile /etc/apache2/ssl/mycerficate.crt
SSLCertificateKeyFile /etc/apache2/ssl/mykey.key
SSLCertificateChainFile /etc/apache2/ssl/mychain.crt


# Django settings
WSGIScriptAlias / /path/to/my/project/wsgi.py

<Directory /path/to/my/project/>
Options -Indexes
AllowOverride All
Order allow,deny
Allow from all
    </Directory>

new.sample.com 配置文件

<VirtualHost xx.xx.xx.xx:80>

ServerName new.sample.com 
ServerAlias new.sample.com

WSGIPassAuthorization On
# Django settings
WSGIScriptAlias / /path/to/my/project/wsgi_new.py

</VirtualHost>

答案1

目前,您只为端口 443 的请求配置了一个虚拟主机。如果某个特定端口没有虚拟主机Hostname:,Apache 将使用该特定端口配置的第一个虚拟主机来响应 HTTP 请求IP 地址 / 端口号组合。

需要为new.sample.com监听 443 端口的主机名创建虚拟主机配置:

<VirtualHost xx.xx.xx.xx:443>
    ServerName new.sample.com 
    SSLEngine On
    ...
    WSGIPassAuthorization On
    WSGIScriptAlias / /path/to/my/project/wsgi_new.py
</VirtualHost>

相关内容