Chinaunix首页 | 论坛 | 博客

linuxman(霍子)poet.blog.chinaunix.net

we are flying.....

  • 博客访问: 125367
  • 博文数量: 54
  • 博客积分: 497
  • 博客等级: 下士
  • 技术积分: 607
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-16 20:05
个人简介

行动…Don\'t ever let somebody tell you, you can\'t do something. you got a dream, you gotta protect it. people can\'t do something themselves they wanna tell you you can\'t do it.if you want something. go get it.

文章分类

全部博文(54)

文章存档

2018年(1)

2017年(18)

2016年(9)

2015年(4)

2013年(1)

2011年(21)

我的朋友

分类: 系统运维

2017-12-01 11:40:36

user  root root;

worker_processes  8;
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 1000000;

error_log /home/openresty/nginx/logs/error.log crit;

worker_rlimit_nofile 65535;

events {
    accept_mutex on;
    multi_accept on;
    use epoll;
    worker_connections  65535;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    proxy_buffering off;
    charset UTF-8;
    log_escape_non_ascii off;
    
    server_names_hash_bucket_size 128;
    client_header_buffer_size 2k;
    large_client_header_buffers 4 4k;
    client_max_body_size 8m;
    sendfile on;
    access_log off;
    gzip off;
    keepalive_requests 8192;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request"'
    #access_log  logs/access.log  main;
    access_log off;
    log_format  postdata  '$request_body|';
    tcp_nopush     on;
    #keepalive_timeout  0;
    tcp_nodelay on;
    #gzip  on;
    client_header_timeout 12;
    keepalive_timeout 15;
    send_timeout 10;
    open_file_cache max=100000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;
#lua调用的文件路径
    lua_package_path "/home/openresty/lualib/kafka/?.lua;;";
    resolver 127.0.0.1;

    map $host $fmt_localtime {
                 default '';
                }
   server {
        listen       8007;
        server_name  172.1.11.18;
        client_max_body_size  10m;
        client_body_buffer_size  128k;
        proxy_connect_timeout 90;
        proxy_send_timeout 90;
        proxy_read_timeout 90;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;       
        server_tokens off;
        set $resp_body "";
#取时间,对日志进行每小时切割
        location / {
        if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})")
          {
            set $year $1;
            set $month $2;
            set $day $3;
            set $hour $4;
            #set $minutes $5;
            #set $seconds $6;
          }
        lua_need_request_body on;
        fastcgi_keep_conn on;
        content_by_lua '
                local resp_body = ngx.req.get_body_data();
                local producer = require "resty.kafka.producer"
#kafka集群
                   local broker_list = {
                         { host = "172.2.0.3", port = 9092 },
                         { host = "172.2.0.4", port = 9092 },
                          { host = "172.2.0.5", port = 9092 },
                        }
#向KAFKA转发日志               
            local bp = producer:new(broker_list, { producer_type = "async" })
             local ok, err = bp:send("apkmsg", nil, resp_body.."|")
    
                 if not ok then
                       ngx.log(ngx.ERR, err)
                       return ngx.exit(200)
                  end
                  ngx.say("success")

            ';

     access_log  /data/new_collect/log/$year.$month.$day.$hour.evt postdata;

}
        location /nginx_status {
                stub_status on;
                access_log off;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
阅读(35) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
请登录后评论。

登录 注册