rubynginxgeoipmaxmind

Maxmind Geoip city encoding issue


When configuring Max Mind with Nginx (using something like proxy_set_header GEOIP_CITY $geoip_city;), I get encoding issues with the city name when it has accents in it (like Montréal).

I’ve search everywhere and I can’t find an nginx switch to force utf-8 encoding. What am I missing?

I tried to city.force_encoding('iso-8859-1').encode('utf-8') on ruby's side, but no dice.

Thanks!


Solution

  • Although it isn't documented, it appears that you can force the Nginx module to use UTF-8. To use this, I believe you load the database in the following manner:

    http {
        geoip_city            GeoLiteCity.dat  utf8;
        ...