Why all the mismatched traffic goes to the first VirtualHost, and not by default to the httpd.conf site configuration

I always wondered why all the inappropriate traffic goes to the first VirtualHost, and not to the default site configuration httpd.conf?

Suppose httpd.conf has not been edited.

I create a file called /etc/httpd/conf.d/vhost.conf

With the following:

<VirtualHost *:80>
        ServerName website.com
        ServerAlias www.website.com
        DocumentRoot "/site1"
        <Directory "/site1">
                AllowOverride All
                Require all granted
        </Directory>

        Some Rules Here
</VirtualHost>
<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        DocumentRoot "/site2"
        <Directory "/site2">
                AllowOverride All
                Require all granted
        </Directory>

        Some Rules Here
</VirtualHost>

In the above example, if you send a request to stackoverflow.com, you should be filtered in the first vhost, no matter what filters, and not the default website in httpd.conf

What am I missing?

+4
source share
1 answer

; Apache :

Apache - ( ), ; -, httpd.conf. ( IP-, Apache "" ) , Apache:

-, <VirtualHost> . ServerName DocumentRoot, , , ServerName DocumentRoot. , .

, :

, , IP-.

, . DocumentRoot , IP- NameVirtualHost. , , <VirtualHost> .


Apache, , . ,

IP: port , , , IP: , ServerName ServerAlias. SSL-, .

vhost IP- Host: (, HTTP/1.0).

+3

All Articles