Apache VirtualHost Issue

Asked by Alakananda Santhakumari

Hello,

I am currently using an AWS EC2 (ubuntu 20.04) machine. I have installed apache2 and configured a two new sites at /var/www/myapp/myapp.html and /var/www/mynew/mynew.html. I created a new virtualhost file at the location /etc/apache/sites-available/myapp.conf. I have added 2 virtual host entries corresponding to the above sites. Enabled the myapp.conf file (a2ensite myapp.conf) and disabled the default virtualhost file (000-default.conf). As an experiment i put wrong IP:port combinations for the virtualhost directives , so that my request will not match any of the virtualhost. When i am trying to access the server , it serves the default webpage. But i was expecting the 1st virtualhost content.
Does anyone know why the disabled default webpage is displayed if no virtualhost matching the requested IP:port?

I have tried a different scenario, i changed the name of the default VirtualHost file from "000-default.conf" to "napp-default.conf", because i read somewhere that apache will read the VirtualHost files in the alphabetical order (my assumption was myapp.conf will be read first before napp-default.conf). But unfortunately i am getting the same output (default webpage) for the "nothing matches" scenario.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu apache2 Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Bernard Stafford (bernard010) said (last edit ):
#1

https://httpd.apache.org/docs/2.4/
https://httpd.apache.org/docs/2.4/vhosts/
Documentation for Apache.
Virtual Host Support
Configuration directives

Can you help with this problem?

Provide an answer of your own, or ask Alakananda Santhakumari for more information if necessary.

To post a message you must log in.