Skip to content

Instantly share code, notes, and snippets.

@droM4X
Last active May 29, 2021 09:13
Show Gist options
  • Save droM4X/2ccdc20b22e91bdc6aa621b33faf8ac5 to your computer and use it in GitHub Desktop.
Save droM4X/2ccdc20b22e91bdc6aa621b33faf8ac5 to your computer and use it in GitHub Desktop.
Nginx GeoIP2 builder
#!/usr/bin/env bash
# docs: https://dokov.bg/nginx-geoip2/
echo "### nginx geoip2 builder ###"
echo "Enter nginx version: (f.g.: 1.21.0)"
read NGINX_VERSION
NGINX_SOURCE="https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"
echo "--- download sources ---"
rm -rf ./nginx_build
mkdir nginx_build
curl -sL ${NGINX_SOURCE} --output nginx_source.tar.gz
tar -zxf nginx_source.tar.gz --directory ./nginx_build
cd nginx_build/*
curl -sL https://github.com/leev/ngx_http_geoip2_module/archive/master.tar.gz --output ngx_http_geoip2_module.tar.gz
tar -zxf ngx_http_geoip2_module.tar.gz
echo "--- build ngx geoip2 module ---"
./configure --add-dynamic-module="./ngx_http_geoip2_module-master" $(nginx -V) --with-compat
make
cp objs/ngx_http_geoip2_module.so /opt/nginx/modules/
echo "--- cleanup ---"
cd ../../
rm ./nginx_source.tar.gz
rm -rf ./nginx_build
echo "--- nginx geoip2 builder finished ---"
echo "module file copied to /opt/nginx/modules"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment