Configure nginx to limit IP access times

Source: Internet
Author: User

Modify the nginx configuration file on the server

/Usr/local/nginx/CONF/nginx. conf

HTTP {

Limit_req_zone $ binary_remote_addr zone = one: 10 m rate = 3000r/m;

Proxy_cache_path/var/Cache/nginx levels = keys_zone = one: 8 m max_size = 3000 m inactive = 600 m;

Proxy_temp_path/var/tmp;


Include mime. types;

Default_type application/octet-stream;


Gzip on;

Gzip_comp_level 6;

Gzip_vary on;

Gzip_min_length 1000;

Gzip_proxied any;

Gzip_types text/plain text/HTML text/CSS application/JSON application/X-JavaScript text/XML application/XML + RSS text/JavaScript;

Gzip_buffers 16 8 K;


# Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'

# '$ Status $ body_bytes_sent "$ http_referer "'

# '"$ Http_user_agent" "$ http_x_forwarded_for "';


# Access_log logs/access. Log main;


Sendfile on;

# Tcp_nopush on;


# Keepalive_timeout 0;

Keepalive_timeout 65;


# Gzip on;


Upstream wedate {

Server 10.0.0.48: 8080;

Server 10.0.0.50: 8080;

}

Server {

Listen 8080;

SERVER_NAME localhost;


# Charset koi8-r;


# Access_log logs/host. Access. Log main;


Location /{

Limit_req zone = wedate_zone burst = 30;

Proxy_redirect off;

Proxy_set_header X-real-IP $ remote_addr;

Proxy_set_header X-forwarded-for $ proxy_add_x_forwarded_for;

Proxy_set_header X-forwarded-Proto $ scheme;

Proxy_set_header host $ http_host;

Proxy_set_header X-nginx-proxy true;

Proxy_set_header connection "";

Proxy_http_version 1.1;

Proxy_cache one;

Proxy_cache_key SFS $ request_uri $ scheme;

Proxy_pass http: // wedate;

}

Nginx smooth restart,

Nginx-t-c/usr/local/nginx/CONF/nginx. conf


Configure nginx to limit IP access times

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.