Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to new mirrorbrain image - Oct 2023 #135

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions zim/download-kiwix/mb-configs.cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ data:
#LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
#LoadModule remoteip_module modules/mod_remoteip.so
LoadModule remoteip_module modules/mod_remoteip.so
#LoadModule proxy_module modules/mod_proxy.so
#LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
Expand Down Expand Up @@ -218,7 +218,7 @@ data:
#LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule geoip_module modules/mod_geoip.so
LoadModule maxminddb_module modules/mod_maxminddb.so
LoadModule form_module modules/mod_form.so
LoadModule mirrorbrain_module modules/mod_mirrorbrain.so
LoadModule autoindex_mb_module modules/mod_autoindex_mb.so
Expand Down Expand Up @@ -324,7 +324,7 @@ data:
# Custom `vhost` log format that we use on nginx as well
# and which is adapted for matomo-log-uploader
# log_format vhost '$host $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
LogFormat "%v %{X-Forwarded-For}i - %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost

<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
Expand Down Expand Up @@ -388,6 +388,11 @@ data:
#Scriptsock cgisock
</IfModule>

<IfModule remoteip_module>
# Use the X-Forwarded-For header as useragent IP
RemoteIPHeader X-Forwarded-For
</IfModule>

#
# "/usr/local/apache2/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
Expand Down Expand Up @@ -669,6 +674,8 @@ data:
ServerAdmin [email protected]
DocumentRoot /var/www/download.kiwix.org

Alias /static/ /var/www/static/

MirrorBrainMetalinkPublisher "Kiwix project" https://kiwix.org
MirrorBrainTorrentTrackerURL "http://tracker.openzim.org:6969/announce"
MirrorBrainTorrentTrackerURL "udp://tracker.openzim.org:6969/announce"
Expand All @@ -693,10 +700,18 @@ data:
ExpiresByType text/xml "access plus 60 minutes"
</IfModule>

<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPEnableUTF8 On
GeoIPScanProxyHeaders On
<IfModule maxminddb_module>
MaxMindDBEnable On
#MaxMindDBFile COUNTRY_DB /usr/share/GeoIP/GeoLite2-Country.mmdb
MaxMindDBFile CITY_DB /usr/share/GeoIP/GeoLite2-City.mmdb
# we use old DBEnv names to not modify mirrorbrain code
MaxMindDBEnv GEOIP_COUNTRY_CODE CITY_DB/country/iso_code
MaxMindDBEnv GEOIP_COUNTRY_NAME CITY_DB/country/names/en
MaxMindDBEnv GEOIP_CONTINENT_CODE CITY_DB/continent/code
MaxMindDBEnv GEOIP_LONGITUDE CITY_DB/location/longitude
MaxMindDBEnv GEOIP_LATITUDE CITY_DB/location/latitude
MaxMindDBEnv GEOIP_REGION CITY_DB/subdivisions/0/iso_code
MaxMindDBEnv GEOIP_REGION_NAME CITY_DB/subdivisions/0/names/en
</IfModule>

# This is a hack to avoid counting twice a same
Expand Down Expand Up @@ -750,3 +765,23 @@ data:
IndexOrderDefault Descending Date
</Directory>
</VirtualHost>
mirrorlist_header.txt: |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<base href="http://download.kiwix.org/static/" />

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>%(title)s</title>
<link type="text/css" rel="stylesheet" href="mirrorbrain.css" />
<link href="/favicon.ico" rel="shortcut icon" />

<meta http-equiv="Language" content="en" />
<meta name="description" content="Download Mirrors" />
<meta name="keywords" content="download metalink redirector mirror mirrors" />
<meta name="author" content="MirrorBrain" />
<meta name="robots" content="index, nofollow" />
</head>

<body>
8 changes: 6 additions & 2 deletions zim/download-kiwix/mirrorbrain-web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ spec:
mountPath: "/usr/share/mirrorbrain"
readOnly: true
- name: mb-volume
subPath: geoip
mountPath: "/usr/local/geoip/share/GeoIP"
subPath: geoip2
mountPath: "/usr/share/GeoIP"
readOnly: true
- name: configs
subPath: mirrorbrain.conf
Expand All @@ -50,6 +50,10 @@ spec:
subPath: httpd-vhosts.conf
mountPath: "/usr/local/apache2/conf/extra/httpd-vhosts.conf"
readOnly: true
- name: configs
subPath: mirrorlist_header.txt
mountPath: "/etc/mirrorlist_header.txt"
readOnly: true
- mountPath: "/usr/local/apache2/logs/custom"
subPath: download-kiwix
name: nginx-logs-volume
Expand Down
4 changes: 2 additions & 2 deletions zim/download-kiwix/tasks/mb-probe-mirrors.cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ spec:
command: ["mirrorprobe"]
volumeMounts:
- name: mb-volume
subPath: geoip
mountPath: "/usr/local/geoip/share/GeoIP"
subPath: geoip2
mountPath: "/usr/share/GeoIP"
readOnly: true
- name: configs
subPath: mirrorbrain.conf
Expand Down
43 changes: 43 additions & 0 deletions zim/download-kiwix/tasks/mb-update-geoip.cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: mb-probe-mirrors
namespace: zim
spec:
schedule: "0 10 * * *"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
concurrencyPolicy: Forbid
jobTemplate:
spec:
backoffLimit: 2
template:
spec:
containers:
- image: ghcr.io/kiwix/mirrorbrain:latest
imagePullPolicy: IfNotPresent
name: mirrorbrain
command: ["geoipupdate -v"]
volumeMounts:
- name: mb-volume
subPath: geoip2
mountPath: "/usr/share/GeoIP"
readOnly: false
- name: mb-secrets
subPath: GeoIP.conf
readOnly: true
mountPath: "/etc/GeoIP.conf"
resources:
requests:
memory: "64Mi"
cpu: "20m"
volumes:
- name: mb-volume
persistentVolumeClaim:
claimName: mirrorbrain-support-pvc
- name: mb-secrets
secret:
secretName: mb-secrets
restartPolicy: Never
nodeSelector:
k8s.kiwix.org/role: "storage"