-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,31 @@ | ||
FROM ubuntu:20.04 AS buildstep | ||
FROM ubuntu:22.04 AS buildstep | ||
ENV TERM=xterm container=docker DEBIAN_FRONTEND=noninteractive \ | ||
NGINX_DEVEL_KIT_VERSION=0.3.1 NGINX_SET_MISC_MODULE_VERSION=0.32 \ | ||
NGINX_VERSION=1.20.2 | ||
NGINX_VERSION=1.22.0 | ||
ADD ./build/ /tmp/ | ||
RUN bash /tmp/ubuntu.sh | ||
|
||
|
||
FROM ubuntu:20.04 | ||
FROM ubuntu:22.04 | ||
LABEL maintainer="noogen <[email protected]>" | ||
ENV TERM=xterm container=docker DEBIAN_FRONTEND=noninteractive \ | ||
NGINX_VERSION=_1.20.2-1~focal_amd64.deb \ | ||
NGINX_VERSION=_1.22.0-1~jammy_amd64.deb \ | ||
NGINX_DEBUG=-dbg${NGINX_VERSION} | ||
|
||
COPY --from=buildstep /usr/src/nginx/nginx${NGINX_VERSION} /tmp | ||
|
||
RUN cd /tmp \ | ||
&& echo "\n\n* soft nofile 800000\n* hard nofile 800000\n\n" >> /etc/security/limits.conf \ | ||
&& apt-get update -y && apt-get upgrade -y --no-install-recommends --no-install-suggests \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests \ | ||
curl gpg-agent nano libgd3 gettext-base unzip rsync cron \ | ||
apt-transport-https software-properties-common \ | ||
ca-certificates \ | ||
&& apt-get install -y --no-install-recommends --no-install-suggests curl gpg-agent nano \ | ||
libgd3 gettext-base unzip rsync cron apt-transport-https software-properties-common \ | ||
ca-certificates libmaxminddb0 libmaxminddb-dev mmdb-bin \ | ||
&& dpkg --configure -a \ | ||
&& touch /var/log/cron.log \ | ||
&& curl -s https://nginx.org/keys/nginx_signing.key | apt-key add - \ | ||
&& cp /etc/apt/sources.list /etc/apt/sources.list.bak \ | ||
&& echo "deb http://nginx.org/packages/ubuntu/ focal nginx" | tee -a /etc/apt/sources.list \ | ||
&& echo "deb-src http://nginx.org/packages/ubuntu/ focal nginx" | tee -a /etc/apt/sources.list \ | ||
&& echo "deb http://nginx.org/packages/ubuntu/ jammy nginx" | tee -a /etc/apt/sources.list \ | ||
&& echo "deb-src http://nginx.org/packages/ubuntu/ jammy nginx" | tee -a /etc/apt/sources.list \ | ||
&& apt-get update -y \ | ||
&& dpkg -i nginx${NGINX_VERSION} \ | ||
&& apt-get install --no-install-recommends --no-install-suggests -y nginx-module-njs gettext-base \ | ||
|
@@ -44,6 +43,7 @@ ADD ./files/root/ /root/ | |
ADD ./files/sbin/ /sbin/ | ||
|
||
RUN bash /root/bin/placeholder-ssl.sh \ | ||
&& bash /etc/cron.daily/geoip2-update \ | ||
&& mkdir -p /app-start/etc \ | ||
&& mv /etc/nginx /app-start/etc/nginx \ | ||
&& rm -rf /etc/nginx \ | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
# download geolite2 file | ||
mkdir -p /usr/share/GeoIP/ | ||
./root/bin/my-download.sh /usr/share/GeoIP/GeoLite2-ASN.mmdb https://git.io/GeoLite2-ASN.mmdb | ||
./root/bin/my-download.sh /usr/share/GeoIP/GeoLite2-City.mmdb https://git.io/GeoLite2-City.mmdb | ||
./root/bin/my-download.sh /usr/share/GeoIP/GeoLite2-Country.mmdb https://git.io/GeoLite2-Country.mmdb |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
location ~ /(geoip|geoipme)/?(?<ip>.*) { | ||
charset utf-8; | ||
add_header Cache-Control no-cache; | ||
set $realip $ip; | ||
|
||
if ($ip = '') { | ||
set $realip $remote_addr; | ||
} | ||
|
||
include /etc/nginx/geolite2.conf; | ||
|
||
default_type application/json; | ||
set $mybody '{"ip":"$realip","country_code":"$geoip2_country_code","region_code":"$geoip2_region","region_name":"$geoip2_region_name","city":"$geoip2_city","zip_code":"$geoip2_postal_code","latitude":"$geoip2_latitude","longitude":"$geoip2_longitude","metro_code":"$geoip2_dma_code"}'; | ||
|
||
if ($arg_format = "xml") { | ||
add_header Content-Type application/xml; | ||
|
||
set $mybody '<Response><IP>$realip</IP><CountryCode>$geoip2_country_code</CountryCode><CountryName>$geoip2_country_name</CountryName><RegionCode>$geoip2_region</RegionCode><RegionName>$geoip2_region_name</RegionName><City>$geoip2_city</City><ZipCode>$geoip2_postal_code</ZipCode><Latitude>$geoip2_latitude</Latitude><Longitude>$geoip2_longitude</Longitude><MetroCode>$geoip2_dma_code</MetroCode></Response>'; | ||
} | ||
|
||
if ($arg_format = "csv") { | ||
add_header Content-Type text/csv; | ||
set $mybody '$realip,$geoip2_country_code,$geoip2_region,$geoip2_region_name,$geoip2_city,$geoip2_postal_code,$geoip2_latitude,$geoip2_longitude,$geoip2_dma_code'; | ||
} | ||
|
||
if ($arg_callback) { | ||
add_header Content-Type application/javascript; | ||
return 200 '$arg_callback($mybody);'; | ||
} | ||
|
||
return 200 $mybody; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
if ($realip = '') { | ||
set $realip $remote_addr | ||
} | ||
|
||
geoip2 /usr/share/GeoIP/GeoLite2-City.mmdb { | ||
auto_reload 60m; | ||
|
||
$geoip2_metadata_country_build metadata build_epoch; | ||
$geoip2_data_country source=$realip country names en; | ||
$geoip2_data_country_code source=$realip country iso_code; | ||
} | ||
|
||
geoip2 /usr/share/GeoIP/GeoLite2-City.mmdb { | ||
auto_reload 60m; | ||
|
||
$geoip2_continent_code source=$realip continent code; | ||
$geoip2_country source=$realip country names en; | ||
$geoip2_country_code source=$realip country iso_code; | ||
$geoip2_region source=$realip subdivisions 0 names en; | ||
$geoip2_region_code source=$realip subdivisions 0 iso_code; | ||
$geoip2_city source=$realip city names en; | ||
$geoip2_postal_code source=$realip postal code; | ||
$geoip2_latitude source=$realip location latitude; | ||
$geoip2_longitude source=$realip location longitude; | ||
$geoip2_time_zone source=$realip location time_zone; | ||
$geoip2_dma_code source=$realip location metro_code; | ||
} | ||
|
||
geoip2 /usr/share/GeoIP/GeoLite2-ASN.mmdb { | ||
auto_reload 60m; | ||
|
||
$geoip2_asn source=$realip autonomous_system_number; | ||
$geoip2_organization source=$realip autonomous_system_organization; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
file=$1 | ||
uri=$2 | ||
|
||
if test -e "$file" | ||
then zflag=(-z "$file") | ||
else zflag=() | ||
fi | ||
curl -sLo "$file" "${zflag[@]}" "$uri" | ||
|