File tree 4 files changed +23
-14
lines changed
4 files changed +23
-14
lines changed Original file line number Diff line number Diff line change
1
+ # ref your cdn here, example bunnycdn below
2
+ include cdn/cdn-bunny.conf;
3
+
1
4
# Local cache/proxy
2
5
set_real_ip_from 0.0.0.0/0;
3
6
set_real_ip_from ::/0;
@@ -6,6 +9,17 @@ set_real_ip_from 192.168.0.0/16;
6
9
set_real_ip_from 10.0.0.0/8;
7
10
set_real_ip_from 172.0.0.0/24;
8
11
9
- #real_ip_header X-Real-IP;
10
- #real_ip_header X-Forwarded-For;
11
- #real_ip_recursive on;
12
+ real_ip_header X-Forwarded-For;
13
+ real_ip_recursive on;
14
+
15
+ # map realip to use with geolite2.conf
16
+ map $http_x_forwarded_for $forwarded_ip {
17
+ default $http_x_forwarded_for;
18
+ '' $realip_remote_addr;
19
+ }
20
+
21
+ # simply grab the first IP if there are multiples
22
+ map $forwarded_ip $realip {"~(?<IP>[^,]*),*.*" $IP;}
23
+
24
+
25
+ include geolite2.conf;
Original file line number Diff line number Diff line change 1
- # usage: include /etc/nginx/geoipme.conf;
2
- # this proxy pass to sites-enabled/geoip.conf
1
+ # use this with sites-enabled/1-geoip.conf
3
2
location ~ /(geoip|geoipme)+/(?<ip>.*) {
4
- set $realip $ip;
5
-
6
- if ($realip = '') {
7
- set $realip $realip_remote_addr;
3
+ if ($ip) {
4
+ set $realip $ip;
8
5
}
9
6
7
+ proxy_set_header X-Real-IP $realip;
10
8
proxy_set_header X-Forwarded-For $realip;
11
9
proxy_set_header Host "127.0.0.1";
12
10
proxy_pass "http://127.0.0.1:9081";
13
- }
11
+ }
Original file line number Diff line number Diff line change 1
- map $http_x_forwarded_for $realip {
2
- default $http_x_forwarded_for;
3
- '' $realip;
4
- }
1
+ # $realip is map inside of cdn-ips.conf
5
2
6
3
geoip2 /etc/nginx/GeoLite2-Country.mmdb {
7
4
auto_reload 60m;
File renamed without changes.
You can’t perform that action at this time.
0 commit comments