experiment with geoip in caddy

This commit is contained in:
2024-11-22 11:44:38 +01:00
parent d9fa0659ff
commit eb6d56c2be
6 changed files with 63 additions and 35 deletions

View File

@@ -6,6 +6,7 @@
}
versions ipv4
}
<<<<<<< HEAD
#order geoip before respond
@@ -21,6 +22,9 @@
updateUrl "https://updates.maxmind.com"
updateFrequency 86400 # in seconds
}
=======
order geo_ip first
>>>>>>> e0b5673 (experiment with geoip in caddy)
}
rik.veenboer.xyz \
@@ -127,7 +131,6 @@ ha.rik.veenboer.xyz {
log {
output file /var/log/ha.log
}
route {
@app <<CEL
header({'X-Requested-With': 'io.homeassistant.companion.android'}) ||
@@ -155,6 +158,7 @@ geo.rik.veenboer.xyz {
output file /var/log/geo.log
}
<<<<<<< HEAD
geoip2_vars strict
# strict: Alway ignore 'X-Forwarded-For' header
# wild: Trust 'X-Forwarded-For' header if existed
@@ -176,4 +180,32 @@ geo.rik.veenboer.xyz {
geoip2.location_latitude:{geoip2.location_latitude}
geoip2.location_longitude:{geoip2.location_longitude}
geoip2.location_time_zone:{geoip2.location_time_zone}"
=======
geo_ip {
db_path /data/caddy/GeoLite2-Country.mmdb
}
@local {
maxmind_geolocation {
db_path /data/caddy/GeoLite2-Country.mmdb
allow_countries IT FR
}
}
route {
header X-GeoIP-Country-Code {geoip.country_code}
header X-GeoIP-Country-Name {geoip.country_name}
header X-GeoIP-Region {geoip.region_name}
header X-GeoIP-City {geoip.city_name}
header X-GeoIP-Latitude {geoip.latitude}
header X-GeoIP-Longitude {geoip.longitude}
header X-GeoIP-Postal-Code {geoip.postal_code}
header X-GeoIP-Timezone {geoip.time_zone}
reverse_proxy host:12345 {
header_up X-Test "{geoip_country_name}"
header_down X-Client-IP "{remote_host}"
}
}
>>>>>>> e0b5673 (experiment with geoip in caddy)
}