Prohibit direct access through ip addresses (apache, nginx, iis)

Source: Internet
Author: User

Apache prohibits direct access from IP addresses

Add the following code at the end of the httpd. conf file:

The code is as follows: Copy code

NameVirtualHost 1.1.1.1
# Assume that the ip address to be banned is 1.1.1.1.

<VirtualHost 1.1.1.1>
ServerName 1.1.1.1
<Location/>
Order Allow, Deny
Deny from all
</Location>
</VirtualHost>
# Deny any access requests directly through the IP address 1.1.1.1. If you use 1.1.1.1 for access, the system will prompt that the access is denied.
 
<VirtualHost 1.1.1.1>
DocumentRoot "/var/www/cainiaoer"
ServerName www.111cn.net
</VirtualHost>

# Allow access through the domain name www.111cn.net. The main directory points to/var/www/cainiaoer (assume that the root directory of the website is/var/www/cainiaoer)

Nginx disables ip access

Prohibit IP addresses from accessing the website directly, modify nginx. conf, and add an empty server:

The code is as follows: Copy code

Server {
Server_name _;
Return 404;
}

Disable ip access in iis

Step 1: Open the administrative tools-Internet Information Service (IIS) manager, open the website, and select a site

 
Step 2: Double-click the IP address and domain limit in IIS
 
Step 3: Add a deny entry in the right column


ZPANEL disables ip access

Method: Add the following content to "httpd. conf":

The code is as follows: Copy code

CentOS:/etc/zpanel/configs/apache/httpd. conf

Ubuntu:/etc/zpanel/configs/apache/httpd. conf

# Default entry for any undefined domain or direct IP access

<VirtualHost *: 80>

Redirect 404/

</VirtualHost>

Add and execute

Service httpd restart

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.