nginx.conf.j2
2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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;
}