How do I get native GeoIP support in nginx under Alpine Linux
<p>Under OS X and Ubuntu I use GeoIP in PHP through nginx like this:</p>

<pre><code>nginx.conf:
geoip_country /somepath/GeoIP/GeoIP.dat;
fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;

php:
$country = $_SERVER["GEOIP_COUNTRY_CODE"]
</code></pre>

<p>However under Alpine Linux, the package version of nginx (<code>apk add nginx</code>) doesn't seem to include GeoIP (confirmed by <code>nginx -V</code>).</p>

<p>I could compile nginx from source with <code>--with-http_geoip_module</code>, but then I'd have to update nginx manually, which is not desirable. My current workaround is the following:</p>

<pre><code>ash:
sudo apk add geoid

php:
$country = exec("geoiplookup $_SERVER[REMOTE_ADDR]");
</code></pre>

<p>How do I get native GeoIP support in nginx under Alpine Linux?</p>

<p><strong>Update: <code>geoip_country</code> is not recognised even though I installed from edge.</strong></p>

<pre><code>$ apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.4/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/community/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/edge/main/x86_64/APKINDEX.tar.gz
v3.4.4-36-ge528256 [http://dl-cdn.alpinelinux.org/alpine/v3.4/main]
v3.4.0-4239-gff0f660 [http://dl-cdn.alpinelinux.org/alpine/edge/community]
v3.4.0-4267-ga3e3a29 [http://dl-cdn.alpinelinux.org/alpine/edge/main]
OK: 12899 distinct packages available
$ apk add nginx@edge nginx-mod-http-geoip@edge
(1/5) Installing libressl2.4-libcrypto@edge (2.4.3-r1)
(2/5) Installing pcre (8.38-r1)
(3/5) Installing libressl2.4-libssl@edge (2.4.3-r1)
(4/5) Installing nginx@edge (1.10.1-r9)
Executing nginx-1.10.1-r9.pre-install
(5/5) Installing nginx-mod-http-geoip@edge (1.10.1-r9)
Executing busybox-1.24.2-r11.trigger
OK: 500 MiB in 92 packages
$ rc-service nginx restart
 * Caching service dependencies ...                                                                                             [ ok ]
nginx: [emerg] unknown directive "geoip_country" in /etc/nginx/nginx.conf:1
nginx: configuration file /etc/nginx/nginx.conf test failed                                                                     [ !! ]
 * ERROR: nginx failed to start
</code></pre>