Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save egeneralov/954eea79d9cf95239788b14f85eec33c to your computer and use it in GitHub Desktop.

Select an option

Save egeneralov/954eea79d9cf95239788b14f85eec33c to your computer and use it in GitHub Desktop.
maxmind + 51d + ip2location
#!/bin/bash -xe
# docker run -it --rm --network host -v /tmp/packages:/packages debian
# docker run -it --rm --network host -v /tmp/packages:/packages -v ${PWD}/nginx.sh:/nginx.sh:ro debian /nginx.sh
echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.list
apt-get update -q
apt-get install -yq build-essential curl git dh-autoreconf zlib1g-dev wget libssl-dev libxml2-dev libxslt-dev libgd-dev libgeoip-dev libpcre++-dev checkinstall libmaxminddb0 libmaxminddb-dev
mkdir -p /build /packages
> /packages/1.txt
find /packages -type f | xargs rm
cd /build
git clone https://github.com/chrislim2888/IP2Location-C-Library /build/IP2Location-C-Library
cd /build/IP2Location-C-Library
git checkout 8.0.9
autoreconf -i -v --force
./configure
make
make install
checkinstall \
-D \
--install=no \
--default \
--pkgname=ip2location-c \
--pkgversion=8.0.9 \
--pkgarch=amd64 \
--pkggroup=lib \
--pkgsource="https://github.com/chrislim2888/IP2Location-C-Library" \
--maintainer="Eduard Generalov <[email protected]>" \
--requires=librtmp1 \
--autodoinst=no \
--deldoc=yes \
--deldesc=yes \
--delspec=yes \
--backup=no \
make install
mv /build/IP2Location-C-Library/ip2location-c_8.0.9-1_amd64.deb /packages/
dpkg -i /packages/ip2location-c_8.0.9-1_amd64.deb
ldconfig
[ -d /build/Device-Detection ] || git clone https://github.com/51Degrees/Device-Detection /build/Device-Detection
cd /build/Device-Detection/nginx
git checkout v3.2.21.1
make install VERSION=1.19.0 || make install pattern VERSION=1.19.0 || make install VERSION=1.19.0 || echo 1
[ -d /build/ip2location-nginx ] || git clone https://github.com/ip2location/ip2location-nginx /build/ip2location-nginx
[ -d /build/ngx_http_geoip2_module ] || git clone https://github.com/leev/ngx_http_geoip2_module /build/ngx_http_geoip2_module
cd /build
[ -f nginx-1.19.0.tar.gz ] || wget https://nginx.org/download/nginx-1.19.0.tar.gz
[ -d nginx-1.19.0 ] || tar zxf nginx-1.19.0.tar.gz
cd /build/nginx-1.19.0
./configure \
--with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-tBUzFN/nginx-1.19.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' \
--with-ld-opt='-Wl,-z,relro -Wl,-z,now -fPIC' \
--prefix=/usr/share/nginx \
--conf-path=/etc/nginx/nginx.conf \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--lock-path=/var/lock/nginx.lock \
--pid-path=/run/nginx.pid \
--modules-path=/usr/lib/nginx/modules \
--http-client-body-temp-path=/var/lib/nginx/body \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-scgi-temp-path=/var/lib/nginx/scgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--with-debug \
--with-pcre-jit \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-http_auth_request_module \
--with-http_v2_module \
--with-http_dav_module \
--with-http_slice_module \
--with-threads \
--with-http_addition_module \
--with-http_geoip_module=dynamic \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_image_filter_module=dynamic \
--with-http_sub_module \
--with-http_xslt_module=dynamic \
--with-stream \
--with-stream_ssl_module \
--with-stream_ssl_preread_module \
--with-mail=dynamic \
--with-mail_ssl_module \
--add-module=/build/ip2location-nginx \
--add-module=/build/ngx_http_geoip2_module
make -j 4
make install
checkinstall \
-D \
--install=no \
--default \
--pkgname=nginx \
--pkgversion=1.19.0 \
--pkgarch=amd64 \
--pkggroup=web \
--pkgsource="https://nginx.org/download/nginx-1.19.0.tar.gz" \
--maintainer="Eduard Generalov <[email protected]>" \
--provides=nginx \
--requires=ip2location-c,libssl1.1,libc-bin,libc6,libzstd1,libpcre++0v5,libpcre16-3,libpcre2-8-0,libpcre3,libpcre32-3,libpcrecpp0v5,libmaxminddb0 \
--autodoinst=no \
--deldoc=yes \
--deldesc=yes \
--delspec=yes \
--backup=no \
make install
mkdir -p /build/nginx_deb/DEBIAN
cd /build/nginx_deb
ar x /build/nginx-1.19.0/nginx_1.19.0-1_amd64.deb
tar xJvf control.tar.xz -C DEBIAN
tar xJvf data.tar.xz
rm *.tar.xz debian-binary
find . -name \*.old | xargs rm
for file in $(find . -name \*.default); do
mv $file $(echo $file | sed 's/.default//g');
done
sed -i 's/.default//g' DEBIAN/conffiles
cp /build/Device-Detection/nginx/build/modules/ngx_http_51D_module.so ./usr/lib/nginx/modules/ngx_http_51D_module.so
mkdir -p var/lib/nginx/body var/log/nginx
dpkg -b ${PWD} /packages/nginx_1.19.0-1_amd64.deb
exit 0
#!/bin/bash -xe
# docker run -it --rm --network host -v /tmp/packages:/packages debian
apt-get update -q
ls -lha /packages/*.deb
dpkg -i /packages/*.deb || apt-get install -fyq
/usr/share/nginx/sbin/nginx -g 'daemon off;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment