Nginx Module Reference manual: HTTP access control module

Source: Internet
Author: User
Keywords Http nginx http access control module module reference manual
Tags 192.168.1.1 access access control aliyun based checking client compiled

These modules are all compiled into Nginx by default unless a module is manually specified to be excluded in configure.

This module provides a simple host-based http://www.aliyun.com/zixun/aggregation/38609.html "> access control."
Nginx_http_access_module This module can be accessed by checking client IP for access control.
Control rules are checked in the order they are declared, and the first matching IP access rule is enabled.
The following example:

Location/{deny 192.168.1.1; allow 192.168.1.0/24; allow 10.1.1.0/16; deny all;}

The above example allows only 192.168.1.0/24 and 10.1.1.0/16 network segments to access this location field, but 192.168.1.1 is an exception.
Note the order of the rules, if you have used Apache you may think you can control the order of the rules and they can work properly, but in practice, the following example will reject all connections:

Location/{#这里将永远输出403错误. Deny all; #这些指令不会被启用 because the arriving connection was already rejected in the first one deny 192.168.1.1; Allow 192.168.1.0/24; Allow 10.1.1.0/1}

If you want to implement a number of complex rules, it is best to use GEOIP module modules.

Instructions

Allow

Syntax: Allow [address | CIDR | ALL]
Default value: No
Working with fields: HTTP, server, location, limit_except
Variables: None
directive specifies the IP or network segment that is allowed to access.

Deny

Syntax: Deny [address | CIDR | ALL]
Default value: No
Working with fields: HTTP, server, location, limit_except
Variables: None
directive specifies an IP or network segment that is denied access.

Tips and Tricks

The Httpaccess module can be used with the error_page instruction to redirect an unauthenticated access request.

Error_page 403 http://example.com/forbidden.html;location/{deny 192.168.1.1; allow 192.168.1.0/24; allow 10.1.1.0/16; Deny all;}
Related Article

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.