-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnginx.conf
118 lines (98 loc) · 3.09 KB
/
nginx.conf
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
108
109
110
111
112
113
114
115
116
117
#user root;
worker_processes 8;
error_log logs/error.log;
pid logs/nginx.pid;
daemon on;
events {
use epoll;
worker_connections 1024;
}
http {
lua_code_cache on;
lua_package_path "${prefix}/plugins/?.lua;;";
init_worker_by_lua_file plugins/InitWorker.lua;
upstream backend {
# only a fake server, set it to an arbitrary value
server 127.0.0.1:8080;
balancer_by_lua_file plugins/Balancer.lua;
keepalive 100;
}
include mime.types;
default_type application/octet-stream;
log_format main '[$request_time|$upstream_response_time]$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_nodelay on;
keepalive_timeout 0;
#gzip on;
upstream test_backend {
server 127.0.0.1:20000;
server 127.0.0.1:20001;
server 127.0.0.1:20002;
server 127.0.0.1:20003;
server 127.0.0.1:20004;
server 127.0.0.1:20005;
server 127.0.0.1:20006;
server 127.0.0.1:20007;
server 127.0.0.1:20008;
server 127.0.0.1:20009;
server 127.0.0.1:20010;
server 127.0.0.1:20011;
server 127.0.0.1:20012;
server 127.0.0.1:20013;
server 127.0.0.1:20014;
server 127.0.0.1:20015;
server 127.0.0.1:20016;
server 127.0.0.1:20017;
server 127.0.0.1:20018;
server 127.0.0.1:20019;
server 127.0.0.1:20020;
server 127.0.0.1:20021;
server 127.0.0.1:20022;
server 127.0.0.1:20023;
server 127.0.0.1:20024;
server 127.0.0.1:20025;
server 127.0.0.1:20026;
server 127.0.0.1:20027;
server 127.0.0.1:20028;
keepalive 100;
}
server {
listen 8484;
server_name localhost;
location / {
proxy_pass http://test_backend;
}
}
server {
listen 8282;
server_name localhost;
location / {
default_type text/plain;
# TODO: set proxy timeout
# TODO: set proxy retries
#proxy_next_upstream error timeout http_502 http_503 http_504;
#proxy_next_upstream_tries 3;
#proxy_next_upstream_timeout 5s;
proxy_set_header Host $host;
proxy_set_header Request-Id $http_request_id;
add_header Request-Id $http_request_id always;
add_header Upstream-Addr $upstream_addr always;
add_header Upstream-Status $upstream_status always;
proxy_pass http://backend;
log_by_lua_file plugins/Log.lua;
}
}
server {
listen 8383;
server_name localhost;
root .;
auth_basic "Enter your username and password first.";
auth_basic_user_file ./user.htpasswd;
location = /available_upstreams {
content_by_lua_file plugins/GetAvailableUpstreams.lua;
}
}
}