-1

The Apache2 Debian Default Page is displayed when I navigate my browser to a domain name pointing to my web server even though I have disabled all the sites/VirtualHosts on my web server. What I expect to see is a "Cannot connect to the server" message.

In other words: Why is Apache displaying the default page when no VirtualHosts are enabled.

The browser is not loading the page from the cache.

I'm using Apache 2.4.33

Edit (when closed as duplicate):

This question is not a duplicate because their VirtualHost files are not disabled.

This answer does answer my question but the answer is to a broader question. I suggest it would be useful to have a similar answer here since my question is more direct and would help others who are wondering the same thing.

  • I know I can stop the server using `sudo systemctl stop apache2` so is the default page supplied just for testing purposes? It seems strange that the default site points to `/var/www/html` and disabling does not stop access to that folder. – David Johnson Apr 01 '18 at 04:57
  • Possible duplicate of [Apache accepting requests to other servers?](https://serverfault.com/questions/662262/apache-accepting-requests-to-other-servers) – Jenny D Apr 01 '18 at 06:31
  • When you stop it do you get a "cannot connect" error? I just want to check there's no other server / instance running. What happens when you have a single virtual host that returns say a 400 status code? – Tim Apr 01 '18 at 08:06
  • @Tim I confirm when I stop it I get the "Cannot connect" error. There is no other instance running it's a fresh AWS Ubuntu instance with a fresh Apache 2.4.33 install. No Virtual Hosts are enabled. I believe the setting in `apache2.conf` is being used as stated in Jenny D's answer [here](https://serverfault.com/a/520201/462994). – David Johnson Apr 01 '18 at 08:25
  • Having no virtual hosts enabled seems like a fairly pointless config. Have one enabled. I'm not sure that this is a valuable question because there's no real problem associated with it. – Tim Apr 01 '18 at 09:05
  • Apache always has a default server that will answer. If you don't want an answer, stop Apache. – Sven Apr 01 '18 at 09:05
  • The value is that someone might think that on a new install disabling the default site will hide the default page and stop all access while they set up Apache. Note that Ubuntu starts the server straight away on install. But your answers are either stop the server or enable at least one Virtual host. So why not have that as the answer so I can accept it? It's a valid question IMHO. – David Johnson Apr 01 '18 at 09:17

1 Answers1

1

Apache always has a default server that will answer and you can't turn that off (if you try to remove the relevant directives, Apache will fail to start because it's not a valid config file then). If you don't want it to serve requests, you must disable the service (aka stop Apache).

It wouldn't make any sense at all to have a service running that can't do anything.

Sven
  • 97,248
  • 13
  • 177
  • 225