Nginx access control and log processing

Source: Internet
Author: User
Keywords Nginx access control log processing
Tags access access control aliyun apache2 control data directory html

Nginx http://www.aliyun.com/zixun/aggregation/38609.html "> access control

1.Nginx ID Card Verification

#cd/usr/local/nginx/conf
#mkdir htpasswd
/usr/local/apache2/bin/htpasswd-c/usr/local/nginx/conf/htpasswd/tongji Linuxtone
#添加用户名为linuxtone
New Password: (enter your password here)
Re-type New Password: (enter your password again)
Adding password for user

http://count.linuxtone.org/tongji/data/index.html (Directory exists/data/www/wwwroot/tongji/data/directory)
The next configuration is placed in the virtual host directory, which prompts for http://count.linuxtone/tongji/when Access is available:

Location ~ ^/(Tongji)/{
Root/data/www/wwwroot/count;
Auth_basic "Lt-count-tongji";
Auth_basic_user_file/usr/local/nginx/conf/htpasswd/tongji;
}

2.Nginx prevents access to files of a certain type.

For example, Nginx access to *.txt files is prohibited, as follows.

Location ~*. (Txt|doc) $ {
if (-f $request _filename) {
Root/data/www/wwwroot/linuxtone/test;
#rewrite ... can be redirected to a URL
Break;
}
}

Method 2:

Location ~*. (Txt|doc) ${
Root/data/www/wwwroot/linuxtone/test;
Deny all;
}

Instance:

Prohibit access to a directory

Location ~ ^/(INF)/{
Deny all;
}

3. Using Ngx_http_access_module to restrict IP access

Location/{
Deny 192.168.1.1;
Allow 192.168.1.0/24;
Allow 10.1.1.0/16;
Deny all;
}
See more Wiki:http://wiki.codemongers.com/nginxhttpaccessmodule#allow

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.