Last active
May 29, 2021 09:13
-
-
Save droM4X/2ccdc20b22e91bdc6aa621b33faf8ac5 to your computer and use it in GitHub Desktop.
Nginx GeoIP2 builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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