
#user  nobody;
worker_processes  2;

error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;


events {
    worker_connections  20480;
}

# load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
#    load ngx_http_fastcgi_module.so;
#    load ngx_http_rewrite_module.so;
#}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" "$upstream_response_time"';

    access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

	lua_package_path "/opt/tengine/conf/waf/?.lua";
	lua_shared_dict limit 100m;
	init_by_lua_file  /opt/tengine/conf/waf/init.lua; 
	access_by_lua_file /opt/tengine/conf/waf/waf.lua;
	#limit_req_zone $http_x_forwarded_for zone=one:3m rate=3r/s;
        #limit_req_zone $http_x_forwarded_for $uri zone=two:3m rate=2r/s;
        #limit_req_zone $http_x_forwarded_for $request_uri zone=three:3m rate=1r/s;

upstream web{
	server xxxxx:80 weight=5; 
	server xxxxx:80 weight=5;
	#check interval=5000 rise=2 fall=3 timeout=3000 type=http;
	
}



    server {
        listen       80;
        server_name  localhost;

        charset gb2312;
       root  html;

        access_log  logs/access.log  main;

location / {
         #limit_req zone=one burst=5;
    #limit_req zone=two forbid_action=@test1;
    #limit_req zone=three burst=3 forbid_action=@test2;
	proxy_pass   http://web;
             proxy_set_header   Host             $host;
             proxy_set_header   X-Real-IP        $remote_addr;
             proxy_set_header   X-Forwarded-For  $http_x_forwarded_for;
	}

location /off {
    limit_req off;
	}

location @test1 {
    return 403;
	}

location @test2 {
    return 403;
	}	

}

}
