ruby - Maxmind Geoip 城市编码问题

标签 ruby nginx geoip maxmind

在使用 Nginx 配置 Max Mind 时(使用类似 proxy_set_header GEOIP_CITY $geoip_city; 的东西),当城市名称中有重音符号时(如蒙特利尔),我会遇到编码问题。

我到处搜索,找不到强制 utf-8 编码的 nginx 开关。我错过了什么?

我尝试在 ruby​​ 方面 city.force_encoding('iso-8859-1').encode('utf-8'),但没有骰子。

谢谢!

最佳答案

虽然没有记录,it appears您可以强制 Nginx 模块使用 UTF-8。要使用它,我相信您可以按以下方式加载数据库:

http {
    geoip_city            GeoLiteCity.dat  utf8;
    ...

关于ruby - Maxmind Geoip 城市编码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32356640/

相关文章:

c++ - 如何让 WebSocket 服务器在 aws 上运行

nginx - Kibana 4,Logstash 仪表板 : how do I require Nginx authentication when saving but allow anonymous views?

apache - 将 CloudFlare 和 MaxMind 的 GeoIP 与 mod_geoip 一起使用时,如何获取用户的 IP?

css - Heroku 没有更新我的 CSS 和 JS

ruby - 在 Ruby/Rails 中清理文件名

关闭端口 80 的 nginx 上的 http 和 https 重定向

javascript - 如何匹配我创建的列表中的国家/地区,然后在该国家/地区在列表内时采取行动? (GeoIP 重定向)

php - 如何在 PHP 项目中创建 GeoIP 功能?

用于自定义标记语言的 Ruby 标记解析器

ruby - 什么相当于 rspec 的 'it "在 minitest/spec 中应该是 …", focus: true do'