Search code examples
google-app-engineipwhitelist

Limiting access to users of given countries/regions with GAE (Java)


I'm looking for a way to tell Google App Engine (Java) not to serve static resources if they're accessed from a specific region/country. What I'd like to achieve is users to be redirected to a special page saying that the website is currently not available for their country when they try to access it from a disallowed country.

I know it's possible to identify a request origin by means of special headers, but that doesn't apply to static content, which is directly managed by the Google CDN.


Solution

  • In a way you almost answered your own question: the only control you have over the static content (served by the Google CDN) is whatever your app's config file allows you to specify for static content.

    And neither app.yaml nor appengine-web.xml support any sort of per-IP address conditioning (neither for static content nor for anything else)

    So the only way I can see of achieving what you're looking for on GAE is to serve everything through your app (where you can obtain the request's origin and enforce some policy based on it) instead of through the Google CDN as static content.