Nginx HTTP access module

Source: Internet
Author: User
Abstract: The HTTP access module provides a simple host name-based access control. This module allows or disables specified IP addresses or IP address segments from accessing certain virtual hosts or directories.

Allow command syntax: Allow [Address | CIDR | all] environment: HTTP, server, Location: allows the specified IP address or IP address segment to access certain virtual hosts or directories deny command syntax: deny [Address | CIDR | all] environment: HTTP, server, Location: prohibit specified IP addresses or IP segments from accessing certain virtual hosts or directory matching rules. The control rules are checked in the declared order. The first access rule matching IP addresses will be used in the demo.
Location/{deny 192.168.1.1; allow 192.168.1.0/24; deny all ;}

Explanation:

1. disable access from the IP address 192.168.1.1. allow access from the IP address range 192.168.1.0/24. However, because 192.168.1.1 matches deny first, 192.168.1.1 cannot be accessed. when the IP address does not match two rules, access from all IP addresses is prohibited.

Different from Apache access rules, those who have used Apache should know that they can control the order of rules and make them work normally (PS: I think this design is silly, it is easy to confuse people), but it is not possible in nginx, because the nginx matching rule is used after the IP address is successfully matched for the first time.
Location/{# Here it will always be 403 deny all; # The following rule will not be enabled, because the incoming connection has been denied on the first rule allow 192.168.1.0/24; allow 10.99.8.1 ;}

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.