>>110329609
https://nginx.org/news.html
#!/usr/bin/env bash
set -e
NGINX_VERSION='1.30.7'
MODULE_VERSION='3.4'
MODULES_DIR='/usr/lib/nginx/modules'
MODULES_CONF='/etc/nginx/modules-enabled/50-nginx-http-geoip2.conf'
NGINX_CONF='/etc/nginx/nginx.conf'
MODULE_INCLUDE='include /etc/nginx/modules-enabled/*.conf;'
sudo apt install -y build-essential libpcre3-dev zlib1g-dev libssl-dev libmaxminddb-dev git
cd /tmp
wget "https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz"
tar xf "nginx-${NGINX_VERSION}.tar.gz"
git clone --branch "$MODULE_VERSION" --depth 1 \
https://github.com/leev/ngx_http_geoip2_module.git
cd "/tmp/nginx-${NGINX_VERSION}"
./configure --with-compat \
--add-dynamic-module=/tmp/ngx_http_geoip2_module
make modules
sudo install -D -m 644 \
objs/ngx_http_geoip2_module.so \
"${MODULES_DIR}/ngx_http_geoip2_module.so"
echo 'load_module modules/ngx_http_geoip2_module.so;' |
sudo tee "$MODULES_CONF" > /dev/null
if ! grep -Fq "$MODULE_INCLUDE" "$NGINX_CONF"; then
echo
echo "Add the following directive to ${NGINX_CONF}, outside all blocks:"
echo
echo "$MODULE_INCLUDE"
echo
read -r -p 'Press Enter once you have added it...'
fi
sudo nginx -t
sudo systemctl reload nginx
echo 'GeoIP2 module installed successfully.'