-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
44 lines (34 loc) · 932 Bytes
/
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
http {
map $geoip_country $allowed_country {
default 1;
GB 0;
RU 0;
# Add other countries as needed
}
server {
listen 9999;
server_name localhost;
set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For;
auth_request @geoip;
auth_request_set $geoip_country $upstream_http_x_geoip_country;
auth_request_set $geoip_city $upstream_http_x_geoip_city;
access_by_lua_block {
local allowed = tonumber(ngx.var.allowed_country)
local geoip_country = ngx.var.geoip_country
if allowed ~= 1 and geoip_country then
ngx.status = 500
ngx.exit(ngx.status)
end
}
location / {
add_header X-Geoip-Country "$geoip_country" always;
}
location = @geoip {
internal;
proxy_pass http://geoip:8080/;
proxy_set_header X-Geoip-Address $remote_addr;
}
}
}
events {}