-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
56 lines (45 loc) · 1.22 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
load_module modules/ngx_http_geoip_module.so;
events { }
error_log stderr;
http {
geoip_country /usr/share/GeoIP/GeoLite2-Country.mmdb;
access_log /dev/stdout;
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=backend_cache:10m inactive=60m;
proxy_cache_key "$scheme$request_method$request_uri";
proxy_cache_valid 200 60m;
proxy_cache_valid 206 60m;
proxy_cache_valid 404 1m;
proxy_cache_bypass $http_pragma;
proxy_cache_revalidate on;
proxy_cache_min_uses 2;
proxy_cache_lock on;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
map $geoip_country_code $backend {
# Define the country code and the corresponding backend server
default server4;
US server1;
CA server2;
IN server3;
}
upstream server1 {
server video-node:3000;
}
upstream server2 {
server video-node-2:3000;
}
upstream server3 {
server video-node-3:3000;
}
upstream server4 {
server video-node-4:3000;
}
server {
listen 80;
location / {
proxy_pass http://$backend;
proxy_cache backend_cache;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}