How can I limit access to website based on region?

Comments

1 comment

  • Justin

    Hi Briana

    In order for the geolocation restriction to work as expected, you need to be using the correct value for `client.geo.region`.

    Looking at the documentation for `client.geo.region` it says it's an alias for `client.geo.region.ascii` (the doc page is here https://docs.fastly.com/vcl/variables/client-geo-region-ascii/ ).

    That page mentions that the variable is either the 2 letter ISO-3166-2 code or for countries where there are smaller subdivisions available it returns that. However, the sample in your code (2 letters and 3 letters separated by a dash) isn't what will be returned.

    You should verify what the value is that you are trying to use block. If you are in the region you can see what is being returned and use that. See this example which shows the value of the region variable as well as the country + region (which is what your code is trying to match against).

    https://fiddle.fastlydemo.net/fiddle/44739a59

    Once you are matching against a valid value you can ensure your code is then doing the right thing.

    Let me know if you if need clarification on this.

    0
    Comment actions Permalink

Please sign in to leave a comment.