Apache Default Virtual Host

Source: Internet
Author: User

Before we configured two domain names: Test and AAA, or access to the IP can also jump to the Discuz forum, there is a concept called the default virtual host configuration file, regardless of which domain name as long as you can parse to the forum, For example, we turn on the computer-C disk-windows-systmes32-drivers-etc-hosts open with a tablet

Join: 192.168.140.100 www.test.com www.aaa.com www.222.com

It can also resolve to 192.168.140.100 this discuz forum to go inside, Ping www.222.com is also to this 192.168.140.100

The conclusion is that no matter what domain name you are, as long as you point it to this server, then it will access to this site, what is this site, is our virtual host inside the first configuration file within the site, this time if we want to limit, such as 222.com It was not my domain name after the resolution can also access my site, which is not in line with the specification of insecurity, so we give it a limit, we put the first site directly rejected

[Email protected] ~]# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

<virtualhost *:80>

documentroot "/tmp/123" this directory does not exist

ServerName 111.com Write it casually

</VirtualHost> is the site in this configuration file

<virtualhost *:80>

DocumentRoot "/data/www/"

ServerName www.test.com

Serveralias www.aaa.com

# errorlog "Logs/dummy-host2.example.com-error_log"

# customlog "Logs/dummy-host2.example.com-access_log" common

<Directory/data/www/abc>

AllowOverride authconfig

AuthName "AAA"

AuthType Basic

authuserfile/data/.htpasswd

Require Valid-user

</Directory>

</VirtualHost>

[Email protected] ~]# ls/tmp/123

LS: Unable to access/tmp/123: No file or directory

[Email protected] ~]# apachectl-t

Warning:documentroot [/tmp/123] does not exist

Syntax error on line of/usr/local/apache2/conf/extra/httpd-vhosts.conf:

Invalid command ' Severname ', perhaps misspelled or defined by a module no included in the server configuration

[Email protected] ~]# mkdir/tmp/123

[Email protected] ~]# chmod 600/tmp/123

[Email protected] ~]# ls-al/tmp/123

Total Dosage 8

DRW-------2 root root 4096 December 27 23:53.

DRWXRWXRWT. 5 root root 4096 December 27 23:53..

[Email protected] ~]# apachectl-t

Syntax error on line of/usr/local/apache2/conf/extra/httpd-vhosts.conf:

Invalid command ' Severname ', perhaps misspelled or defined by a module no included in the server configuration

[Email protected] ~]#!vim

Vim/usr/local/apache2/conf/extra/httpd-vhosts.conf

[Email protected] ~]# apachectl-t

Syntax OK

So Apache it's the default virtual host is the first one, you want to ban it is very simple

    1. Create an empty directory on it, don't add anything inside

    2. Domain Name Write a random

      This is how to disable the default virtual host


This article is from the "Dream On the Ridge" blog, be sure to keep this source http://mengjunlinux.blog.51cto.com/10772888/1729372

Apache Default Virtual host

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.