HTTPS URL在First Configraion上重定向

时间:2017-10-25 10:32:11

标签: apache ssl

当我被点击https://subdomain2.example.com时,页面被称为https://subdomain1.example.com,但是当我在没有HTTPS的情况下点击sub2.example.com时,下面的工作正常我的ssl.config ..给我任何建议对于下面。我的配置中有什么问题

LoadModule ssl_module modules/mod_ssl.so
Listen 443
SSLPassPhraseDialog  builtin
SSLSessionCache         shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout  300
SSLMutex default
SSLRandomSeed startup file:/dev/urandom  256
SSLRandomSeed connect builtin
SSLCryptoDevice builtin

以下是我的SSL配置。

<VirtualHost *:443>
    ServerName  subdomain1.example.com
    ServerAlias subdomain1.example.com
    DocumentRoot /Path/sub1
    ErrorLog logs/ssl_error_log
    TransferLog logs/ssl_access_log
    LogLevel warn
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
    SSLCertificateFile /etc/pki/tls/certs/ServerCertificate2017.crt
    SSLCertificateKeyFile /etc/pki/tls/private/keyw2017.key
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory "/Path/sub1">
        SSLOptions +StdEnvVars
        Options FollowSymLinks -Indexes
        AllowOverride All
        Order deny,allow
        Allow from all
    </Directory>
    SetEnvIf User-Agent ".*MSIE.*" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    CustomLog logs/ssl_request_log \
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>


<VirtualHost *:443>
    ServerName  subdomain2.example.com
    ServerAlias subdomain2.example.com
    DocumentRoot /Path/sub2
    ErrorLog logs/ssl_error_log
    TransferLog logs/ssl_access_log
    LogLevel warn
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
    SSLCertificateFile /etc/pki/tls/certs/ServerCertificate2017.crt
    SSLCertificateKeyFile /etc/pki/tls/private/keyw2017.key
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    </Files>
    <Directory "/Path/sub2/">
        SSLOptions +StdEnvVars
        Options FollowSymLinks -Indexes
        AllowOverride All
        Order deny,allow
        Allow from all
        </Directory>
    SetEnvIf User-Agent ".*MSIE.*" \
        nokeepalive ssl-unclean-shutdown \
        downgrade-1.0 force-response-1.0
    CustomLog logs/ssl_request_log \
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

1 个答案:

答案 0 :(得分:0)

在此配置中需要在SSL配置中添加虚拟主机名,然后它将按照配置工作,否则它将仅考虑第一个配置。 以下是代码..

NameVirtualHost *:443 

OR

NameVirtualHost 192.168.1.1:443