skip to Main Content

I am using Apache httpd and have the following VirtualHost configuration:

<VirtualHost *:443>
    ServerName www.test.site
    ServerAlias test.site
    DocumentRoot /var/www/test.site/html
    ErrorLog /var/www/test.site/log/error.log
    CustomLog /var/www/test.site/log/requests.log combined
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/ca.crt
        SSLCertificateKeyFile /etc/pki/tls/private/ca.key

        <Directory /var/www/html>
                AllowOverride none

                Order Allow,Deny
                Allow from all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName www.test.site
    ServerAlias test.site
    DocumentRoot /var/www/test.site/html
</VirtualHost>

When entering http://test.site in my browser, I see what I want to see.
However, https://test.site returns the Apache test page, even though I specified literally the same DocumentRoot.

What could be the reason? Thanks in advance.

I tried changing the VirtualHost configuration.
I created new certificates, there are no errors with them.

2

Answers


  1. Chosen as BEST ANSWER

    Well, I finally found the problem. In the /etc/httpd/conf.d/ folder, there is an ssl.conf, which contains:

    <VirtualHost _default_:443>
    

    Deleting this, or changing default to 123.123.123.123, solves the problem, although it is arguably not an elegant solution.


  2. Try to delete file 000-default.conf or 000-default-ssl.conf from dir sites-enabled, if exist this one.

    Then change

    <VirtualHost *:80>
        ServerName www.test.site
        ServerAlias test.site
        DocumentRoot /var/www/test.site/html
    </VirtualHost>
    

    To

    <VirtualHost *:80>
        ServerName www.test.site
        ServerAlias test.site
        DocumentRoot /var/www/test.site/html
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =test.site [OR]
    RewriteCond %{SERVER_NAME} =test.site
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
    </VirtualHost>
    

    Good practice to make dummy virtualhost to first place on virtualhost config, like below.

    <VirtualHost *:80>
        ServerName default
        RewriteEngine On
        RewriteRule .* - [G]
    </VirtualHost>
    

    Maybe it is helpful.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search