Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Google App Engine's locations services with proxy

I'm using Nginx as a proxy to filter requests for my AppEngine Java application. GAE's location services (X-AppEngine-country header) works great without the proxy, but now GAE is using the proxy server's IP as client IP, and the X-AppEngine-country header is quite useless - it returns "ZZ" as the country code.

I know that the header is determined by the client IP, as mentioned here:

"X-AppEngine-Country - Country from which the request originated, as an ISO 3166-1 alpha-2 country code. App Engine determines this code from the client's IP address. "

The problem is that I don't know from what data this header is derived. I used Nginx modules to set the client IP in X-Forwarded-For, Remote_Addr and Http_Client_IP headers, but apparently the X-AppEngine-country header is derived from somewhere else.

How can I provide GAE the client IP so it can retrieve the correct country code from the original IP?

like image 901
Peleg Avatar asked Oct 28 '13 08:10

Peleg


1 Answers

You already provided all the info needed for the answer: "..App Engine determines this code from the client's IP address". So they actually look at an IP from where the connection was made.

Since your proxy sits between the client and AppEngine, AppEngine sees connections coming from proxy IP. No way around it.

like image 165
Peter Knego Avatar answered Oct 01 '22 06:10

Peter Knego