Home About Blog

How does the section-io-geo-country header work, and how can I block traffic based on GEO region?

The section.io platform performs GEO region lookup at the Edge and sets a custom header “section-io-geo-country” that contains the ISO 3166-1 alpha-2 country code such as US for the United States, or AU for Australia. There are also a number of other header that are set which can be useful.
See: https://www.section.io/docs/edge-proxy/#ip-geolocation

You can then use the section-io-geo-countryvalue to block traffic in Varnish.

sub vcl_recv {
	if(req.http.section-io-geo-country == "XX") {
		return (synth(403, "Forbidden"));

Replace XX with the country code you would like to block.
You can block multiple countries by using | e.g.req.http.section-io-geo-country == "XX|YY|ZZ"