experiment with geoip in caddy

This commit is contained in:
2024-11-22 11:44:38 +01:00
parent d9fa0659ff
commit eb6d56c2be
6 changed files with 63 additions and 35 deletions

View File

@@ -6,6 +6,7 @@
} }
versions ipv4 versions ipv4
} }
<<<<<<< HEAD
#order geoip before respond #order geoip before respond
@@ -21,6 +22,9 @@
updateUrl "https://updates.maxmind.com" updateUrl "https://updates.maxmind.com"
updateFrequency 86400 # in seconds updateFrequency 86400 # in seconds
} }
=======
order geo_ip first
>>>>>>> e0b5673 (experiment with geoip in caddy)
} }
rik.veenboer.xyz \ rik.veenboer.xyz \
@@ -127,7 +131,6 @@ ha.rik.veenboer.xyz {
log { log {
output file /var/log/ha.log output file /var/log/ha.log
} }
route { route {
@app <<CEL @app <<CEL
header({'X-Requested-With': 'io.homeassistant.companion.android'}) || header({'X-Requested-With': 'io.homeassistant.companion.android'}) ||
@@ -155,6 +158,7 @@ geo.rik.veenboer.xyz {
output file /var/log/geo.log output file /var/log/geo.log
} }
<<<<<<< HEAD
geoip2_vars strict geoip2_vars strict
# strict: Alway ignore 'X-Forwarded-For' header # strict: Alway ignore 'X-Forwarded-For' header
# wild: Trust 'X-Forwarded-For' header if existed # wild: Trust 'X-Forwarded-For' header if existed
@@ -176,4 +180,32 @@ geo.rik.veenboer.xyz {
geoip2.location_latitude:{geoip2.location_latitude} geoip2.location_latitude:{geoip2.location_latitude}
geoip2.location_longitude:{geoip2.location_longitude} geoip2.location_longitude:{geoip2.location_longitude}
geoip2.location_time_zone:{geoip2.location_time_zone}" geoip2.location_time_zone:{geoip2.location_time_zone}"
=======
geo_ip {
db_path /data/caddy/GeoLite2-Country.mmdb
}
@local {
maxmind_geolocation {
db_path /data/caddy/GeoLite2-Country.mmdb
allow_countries IT FR
}
}
route {
header X-GeoIP-Country-Code {geoip.country_code}
header X-GeoIP-Country-Name {geoip.country_name}
header X-GeoIP-Region {geoip.region_name}
header X-GeoIP-City {geoip.city_name}
header X-GeoIP-Latitude {geoip.latitude}
header X-GeoIP-Longitude {geoip.longitude}
header X-GeoIP-Postal-Code {geoip.postal_code}
header X-GeoIP-Timezone {geoip.time_zone}
reverse_proxy host:12345 {
header_up X-Test "{geoip_country_name}"
header_down X-Client-IP "{remote_host}"
}
}
>>>>>>> e0b5673 (experiment with geoip in caddy)
} }

View File

@@ -3,11 +3,16 @@ FROM caddy:2.9-builder AS builder
RUN xcaddy build \ RUN xcaddy build \
--with github.com/caddy-dns/route53 \ --with github.com/caddy-dns/route53 \
--with github.com/mholt/caddy-dynamicdns \ --with github.com/mholt/caddy-dynamicdns \
<<<<<<< HEAD
--with github.com/zhangjiayin/caddy-geoip2 --with github.com/zhangjiayin/caddy-geoip2
#--with github.com/shift72/caddy-geo-ip \ #--with github.com/shift72/caddy-geo-ip \
#--with github.com/aablinov/caddy-geoip \ #--with github.com/aablinov/caddy-geoip \
#--with github.com/porech/caddy-maxmind-geolocation #--with github.com/porech/caddy-maxmind-geolocation
=======
--with github.com/shift72/caddy-geo-ip \
--with github.com/porech/caddy-maxmind-geolocation
>>>>>>> e0b5673 (experiment with geoip in caddy)
FROM caddy:2.9-alpine FROM caddy:2.9-alpine
COPY --from=builder /usr/bin/caddy /usr/bin/caddy COPY --from=builder /usr/bin/caddy /usr/bin/caddy

View File

@@ -6,9 +6,7 @@ services:
extra_hosts: extra_hosts:
- host:192.168.2.200 - host:192.168.2.200
image: kylemanna/openvpn:2.4 image: kylemanna/openvpn:2.4
network_mode: bridge network_mode: host
ports:
- 443:443
privileged: true privileged: true
restart: unless-stopped restart: unless-stopped
volumes: volumes:

View File

@@ -1,9 +1,12 @@
services: services:
seafile: seafile:
build:
context: /opt/seafile/docker/
container_name: seafile container_name: seafile
environment: environment:
- MODE=autorun - MODE=autorun
image: gronis/seafile:10.0.1 # image: gronis/seafile:10.0.1
image: seafile
ports: ports:
- 8100:8000 - 8100:8000
- 8180:8080 - 8180:8080

View File

@@ -1,48 +1,38 @@
# https://github.com/Gronis/docker-seafile/blob/master/Dockerfile FROM --platform=linux/amd64 debian:bullseye-slim
FROM --platform=linux/amd64 debian:bookworm-slim
MAINTAINER Robin Grönerg <robingronberg@gmail.com> MAINTAINER Robin Grönerg <robingronberg@gmail.com>
ENV VERSION=11.0.8 ENV VERSION=11.0.13
ENV DOCKERIZE_VERSION v0.6.1 ENV DOCKERIZE_VERSION v0.6.1
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \ RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
procps python3 python3-dev python3-setuptools python3-pip \ procps python3 python3-dev python3-setuptools python3-pip \
python3-wheel curl sqlite3 default-libmysqlclient-dev \ python3-wheel curl sqlite3 default-libmysqlclient-dev \
build-essential autoconf libtool pkg-config \ build-essential autoconf libtool pkg-config \
libffi-dev libjpeg-dev zlib1g-dev libffi-dev libjpeg-dev zlib1g-dev && \
pip3 install --timeout=3600 \
RUN pip3 install --break-system-packages --timeout=3600 \
pylibmc jinja2 "sqlalchemy<2" python3-ldap \ pylibmc jinja2 "sqlalchemy<2" python3-ldap \
django-pylibmc lxml \ django-pylibmc lxml \
future mysqlclient \ future==0.18.* mysqlclient==2.1.* \
Pillow captcha \ Pillow==9.5.0 captcha==0.5.* \
django_simple_captcha \ django_simple_captcha==0.5.20 \
djangosaml2 pysaml2 \ djangosaml2==1.5.* pysaml2==7.2.* \
pycryptodome cffi pycryptodome==3.16.* cffi==1.15.1 && \
apt-get purge -y \
RUN apt-get purge -y \
python3-dev python3-setuptools python3-pip python3-wheel \ python3-dev python3-setuptools python3-pip python3-wheel \
build-essential autoconf libtool pkg-config build-essential autoconf libtool pkg-config && \
apt-get autoremove -y && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache /usr/share/doc/* && \
RUN apt-get autoremove -y && \ find / -type f -name '*.py[co]' -delete -or -type d -name '__pycache__' -delete && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache /usr/share/doc/* && \ curl -L https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | tar -xz -C /usr/local/bin && \
find / -type f -name '*.py[co]' -delete -or -type d -name '__pycache__' -delete useradd -d /seafile -M -s /bin/bash -c "Seafile User" seafile && \
mkdir -p /opt/haiwen /seafile/
RUN curl -L https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz | tar -xz -C /usr/local/bin
RUN useradd -d /seafile -M -s /bin/bash -c "Seafile User" seafile
RUN mkdir -p /opt/haiwen /seafile/
RUN curl -sL $(curl -sL https://www.seafile.com/en/download/ \ RUN curl -sL $(curl -sL https://www.seafile.com/en/download/ \
| grep -oE 'https://.*seafile-server.*x86-64.tar.gz' \ | grep -oE 'https://.*seafile-server.*x86-64.tar.gz' \
| sed -e "s/[0-9]+\.[0-9]+\.[0-9]+/$VERSION/g" | grep $VERSION \ | sed -e "s/[0-9]+\.[0-9]+\.[0-9]+/$VERSION/g" | grep $VERSION \
| sort -r | head -1) \ | sort -r | head -1) \
| tar -C /opt/haiwen/ -xz | tar -C /opt/haiwen/ -xz \
&& chown -R seafile:seafile /seafile /opt/haiwen
RUN chown -R seafile:seafile /seafile /opt/haiwen
RUN ln -s /usr/bin/python3 /usr/bin/python
COPY ["seafile-entrypoint.sh", "/usr/local/bin/"] COPY ["seafile-entrypoint.sh", "/usr/local/bin/"]
EXPOSE 8000 8082 EXPOSE 8000 8082

View File

@@ -1,7 +1,7 @@
<Config> <Config>
<LogLevel>Info</LogLevel> <LogLevel>Info</LogLevel>
<Port>8989</Port> <Port>8989</Port>
<UrlBase>sonarr</UrlBase> <UrlBase></UrlBase>
<BindAddress>*</BindAddress> <BindAddress>*</BindAddress>
<SslPort>9898</SslPort> <SslPort>9898</SslPort>
<EnableSsl>False</EnableSsl> <EnableSsl>False</EnableSsl>