nginx.conf.j2 2.68 KB
user  www www;

# setup worker proccess and worker cpu affinity 
worker_processes {{processor_count}};
{% if processor_count == '2' %}
worker_cpu_affinity 01 10;
{% elif processor_count == '4' %}
worker_cpu_affinity 1000 0100 0010 0001;
{% elif processor_count >= '8' %}
worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
{% else %}
worker_cpu_affinity 1000 0100 0010 0001;
{% endif %}

pid /Data/local/openresty-1.9.15.1/nginx/logs/nginx.pid;
# [ debug | info | notice | warn | error | crit ]
error_log  /Data/logs/nginx/nginx_error.log error;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;


events {
    worker_connections  1024;
}


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

       log_format fenxi '$remote_addr|$http_x_forwarded_for|[$time_local]|$http_host|$request|'
                        '$status|$body_bytes_sent|$request_time|$upstream_response_time|$upstream_cache_status|$http_referer|'
                        '$http_user_agent|$upstream_addr|'
                        '$real_ip|$request_api_method|$request_uid|$request_udid';


     # limit req configuration   limit for 20r/s for every ip
      geo $limited {
         default           1;
         10.66.0.0/16  0;
         10.67.0.0/16  0;
         192.168.0.0/16  0;
         172.31.0.0/16  0;
      }
     map $limited $limit {
          1        $binary_remote_addr;
          0        "";
      }

     limit_req_zone $limit zone=limit_ufo:90m rate=30r/s;


    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  180;
    client_max_body_size 600m;
    #gzip  on;
    proxy_buffer_size  128k;  
    proxy_buffers   32 32k;  
    proxy_busy_buffers_size 128k;  

    lua_package_path "/Data/local/openresty-1.9.15.1/nginx/conf/lua/?.lua;;";
    init_by_lua_file "conf/lua/init_lua.lua";
    lua_shared_dict upstream  20m;
    init_worker_by_lua_file "conf/lua/init_config_worker.lua";

    server {
        listen       80;
        server_name  localhost;


        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }


 #ufo-gateway
 upstream ufogateway {
    {% for i in groups['java-ufo-fore'] %}
      server {{ i }}:8080 max_fails=5  fail_timeout=3s;
    {% endfor %}
      keepalive 32;
  }


  # ufo-gateway
  upstream ufoplatform {
    {% for i in groups['java-ufo-platform'] %}
      server {{ i }}:8088 max_fails=5  fail_timeout=3s;
    {% endfor %}

      keepalive 100;
  }


	include vhosts/*.conf;

}