Apache2 上的 SSL 子域配置重定向失败

Apache2 上的 SSL 子域配置重定向失败

在我的 Apache2 服务器上,我启用了这 3 个子域名站点。

数据库.example.com

<VirtualHost *:80>
  ServerName database.example.com
  ServerAlias www.database.example.com
  DocumentRoot /usr/share/phpmyadmin/
  Redirect permanent / https://database.example.com
</VirtualHost>

<VirtualHost *:443>
    ServerName  database.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /usr/share/phpmyadmin/

    ErrorLog ${APACHE_LOG_DIR}/database.example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/database.example.com-access.log combined

    SSLEngine On
    SSLCertificateFile /etc/ssl/certs/example.com.cer
    SSLCertificateKeyFile /etc/ssl/private/example.com.key
    SSLCertificateChainFile /etc/ssl/certs/example.com_INTERMEDIATE.cer

</VirtualHost>

staging.example.com

<VirtualHost *:80>
ServerName staging.example.com
ServerAlias www.staging.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/example.com/staging

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

  Redirect permanent / https://staging.example.com

</VirtualHost>

 <VirtualHost *:443>
    ServerName staging.example.com
    ServerAlias www.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/example.com/staging

    ErrorLog ${APACHE_LOG_DIR}/staging.example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/staging.example.com-access.log combined

    SSLEngine On
    SSLCertificateFile /etc/ssl/certs/example.com.cer
    SSLCertificateKeyFile /etc/ssl/private/example.com.key
    SSLCertificateChainFile /etc/ssl/certs/example.com_INTERMEDIATE.cer

 </VirtualHost>

preprod.example.com

<VirtualHost *:80>
ServerName preprod.example.com
ServerAlias www.preprod.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/example.com/preprod

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

 Redirect permanent / https://preprod.example.com

</VirtualHost>

<VirtualHost *:443>
    ServerName preprod.example.com
    ServerAlias www.example.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/example.com/preprod

    ErrorLog ${APACHE_LOG_DIR}/preprod.example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/preprod.example.com-access.log combined

    SSLEngine On
    SSLCertificateFile /etc/ssl/certs/example.com.cer
    SSLCertificateKeyFile /etc/ssl/private/example.com.key
    SSLCertificateChainFile /etc/ssl/certs/example.com_INTERMEDIATE.cer

 </VirtualHost>

数据库和暂存连接工作正常,但尝试连接preprod.example.com服务器时,系统将我重定向到 并database.example.com显示ssl_error_bad_cert_domain错误。我使用的证书由我的域名提供商提供给我,有效期为*.example.com

有人能帮我了解这里的问题是什么并帮我解决吗?非常感谢!

答案1

我发现,我的 Apache2 配置没有问题。WordPress 配置中保存了一个错误的 URL,因此 WordPress 重定向了我的请求。

相关内容