S
S
Sergey2016-03-23 12:23:09
Apache HTTP Server
Sergey, 2016-03-23 12:23:09

How to configure default vhost for https in apache?

I have a bunch of domain names configured on the same server, the first host loaded from /etc/apache2/sites-enabled is used by apache by default. Now if I request a non-existent subdomain for example a.domain2.com, then apache will direct me to default.com and so on for all other domains. I want to disable this and always show a 404 error if no matching vhost exists for the subdomain. For http traffic, I solved this problem by adding the following configuration:

<VirtualHost _default_:80>
    Redirect 404 /
    ErrorDocument 404 "Page Not Found"
</VirtualHost>


Everything works with a bang, I'm doing the same trick for the * .443 port

<VirtualHost _default_:443>
    Redirect 404 /
    ErrorDocument 404 "Page Not Found"
</VirtualHost>


And then my https sites stop opening at all, chrome gives an error that the host cannot provide a secure connection. Sites work without this configuration. How can I achieve the same behavior for https requests as for http?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vlad Zhivotnev, 2016-03-23
Bolotaev @m0nstr0

In VirtualHost _default_:443, you need to add a description of the SSL configuration (certificate and key, at least, still bundle). Well, enable ssl there in principle (SSLEngine on).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question