-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathnginx-glb.conf
104 lines (81 loc) · 2.82 KB
/
nginx-glb.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
user nginx;
worker_processes auto;
load_module modules/ngx_stream_js_module.so;
load_module modules/ngx_stream_geoip2_module.so;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
upstream www_netflix_com {
zone upstream_www_netflix_com 64k;
server 52.49.96.37; # eu-west-1
server 52.51.179.14 backup;
server 52.32.190.151; # us-west-2
server 52.41.193.16 backup;
}
match server_ok {
status 200-399;
}
server {
listen 127.0.0.1:8888;
server_name www.netflix.com;
set $test "foobar";
location / {
proxy_pass http://www_netflix_com;
proxy_set_header Host $host;
proxy_http_version 1.1;
health_check interval=10 fails=3 passes=3 match=server_ok;
}
}
server {
listen 127.0.0.1:80;
location /api/ {
api write=on;
allow 127.0.0.1;
deny all;
}
}
}
stream {
js_include /etc/nginx/njs.d/nginx_stream.js;
js_set $glb_response glb_get_response;
js_set $edns_subnet glb_get_edns_subnet;
keyval_zone zone=glb_config:64k state=/etc/nginx/zones/glb_config.zone;
keyval "www_netflix_com" $www_netflix_com zone=glb_config;
keyval "GLB_USE_EDNS" $glb_use_edns zone=glb_config;
# The following keys are needed if s.api() is unavailable
keyval "www_netflix_com_nodes" $www_netflix_com_nodes zone=glb_config;
keyval "www_netflix_com_geoip_52_49_96_37" $www_netflix_com_geoip_52_49_96_37 zone=glb_config;
keyval "www_netflix_com_geoip_52_51_179_14" $www_netflix_com_geoip_52_51_179_14 zone=glb_config;
keyval "www_netflix_com_geoip_52_32_190_151" $www_netflix_com_geoip_52_32_190_151 zone=glb_config;
keyval "www_netflix_com_geoip_52_41_193_16" $www_netflix_com_geoip_52_41_193_16 zone=glb_config;
# set $geoip_source to EDNS if we have one, or the $remote_addr if not
map $edns_subnet $geoip_source {
"" $remote_addr;
default $edns_subnet;
}
# get the country, latitude, and longitude from the GeoLite2 City DB
geoip2 /etc/geoip/GeoLite2-City.mmdb {
$geoip2_country_code default=GB source=$geoip_source country iso_code;
$geoip2_latitude default=51.52830 source=$geoip_source location latitude;
$geoip2_longitude default=0.0000 source=$geoip_source location longitude;
}
# process the DNS request
server {
listen 192.168.64.20:53 udp reuseport;
js_preread glb_process_request;
return $glb_response;
}
}