summaryrefslogtreecommitdiff
path: root/arch-mirror.home.eckner.net.conf
blob: e1d2b558d9b4b0fdcf2c7a53b0b6afc2df75b4fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
resolver 192.168.0.18 192.168.0.13;

server {
    listen [::]:80;
    listen 80;

    server_name *.arch-mirror.home.eckner.net;
    root        /srv/http/arch-mirror;
    autoindex   on;
}

server {
    listen [::]:80;
    listen 80;
    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/arch-mirror.home.eckner.net/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/arch-mirror.home.eckner.net/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    server_name arch-mirror.home.eckner.net;
    root        /srv/http/arch-mirror;
    autoindex   on;

    # Requests for package db, signature files and files db should redirect upstream without caching
    location ~ /archlinuxewe/os/[^/]+/[^/]+\.(db|sig|files)$ {
        proxy_pass http://mirrorsewe$request_uri;
    }
    location ~ /releng/os/x86_64/([^/]+\.(db|sig|files))$ {
        proxy_pass http://mirrors32/x86_64/releng/$1;
    }

    location ~ ^/([^/]+)/archlinuxewe/([^/]+\.(db|sig|files))$ {
        proxy_pass http://mirrorsewe/archlinuxewe/os/$1/$2;
    }
    location ~ /x86_64/[^/]+\.(db|sig|files)$ {
        proxy_pass http://mirrors$request_uri;
    }
    location ~ /(i[46]86|pentium4)/[^/]+/[^/]+\.(db|sig|files)$ {
        proxy_pass http://mirrors32$request_uri;
    }
    location ~ /(arm(|v6h|v7h)|aarch64)/[^/]+/[^/]+\.(db|sig|files)$ {
        proxy_pass http://mirrorsarm$request_uri;
    }

    # Requests for actual packages should be served directly from cache if available.
    #   If not available, retrieve and save the package from an upstream mirror.
    location ~ /archlinuxewe/os/[^/]+/[^/]+\.tar\.(xz|zst)$ {
        try_files $uri @caches @pkg_mirrorewe;
    }
    location ~ ^/([^/]+)/archlinuxewe/([^/]+\.tar\.(xz|zst))$ {
        try_files /archlinuxewe/os/$1/$2 @caches_reordered @pkg_mirrorewe_reordered;
    }
    location ~ ^/(releng)/os/([^/]+)/([^/]+\.tar\.(xz|zst))$ {
        try_files $uri @caches @pkg_mirror32_reordered;
    }

    location ~ /x86_64/[^/]+\.tar\.(xz|zst)$ {
        try_files $uri @caches @pkg_mirror;
    }
    location ~ /(i[46]86|pentium4)/[^/]+/[^/]+\.tar\.(xz|zst)$ {
        try_files $uri @caches @pkg_mirror32;
    }
    location ~ /(arm(v[67]h)?|aarch64)/[^/]+/[^/]+\.tar\.(xz|zst)$ {
        try_files $uri @caches @pkg_mirrorarm;
    }

    # Retrieve package from cache of another local mirror
    location @caches {
        proxy_store    on;
        proxy_redirect off;
        proxy_store_access  user:rw group:rw all:r;
        proxy_next_upstream error timeout http_404;
        proxy_pass          http://caches$request_uri;
    }
    location @caches_reordered {
        proxy_store    on;
        proxy_redirect off;
        proxy_store_access  user:rw group:rw all:r;
        proxy_next_upstream error timeout http_404;
        proxy_pass          http://caches/$2/$1/$3;
    }

    # Retrieve package from upstream mirrors and cache for future requests
    location @pkg_mirror {
        proxy_store    on;
        proxy_redirect off;
        proxy_store_access  user:rw group:rw all:r;
        proxy_next_upstream error timeout http_404;
        proxy_pass          http://mirrors$request_uri;
    }
    location @pkg_mirror32 {
        proxy_store    on;
        proxy_redirect off;
        proxy_store_access  user:rw group:rw all:r;
        proxy_next_upstream error timeout http_404;
        proxy_pass          http://mirrors32$request_uri;
    }
    location @pkg_mirror32_reordered {
        proxy_store    on;
        proxy_redirect off;
        proxy_store_access  user:rw group:rw all:r;
        proxy_next_upstream error timeout http_404;
        proxy_pass          http://mirrors32/$2/$1/$3;
    }
    location @pkg_mirrorarm {
        proxy_store    on;
        proxy_redirect off;
        proxy_store_access  user:rw group:rw all:r;
        proxy_next_upstream error timeout http_404;
        proxy_pass          http://mirrorsarm$request_uri;
    }
    location @pkg_mirrorewe {
        proxy_store    on;
        proxy_redirect off;
        proxy_store_access  user:rw group:rw all:r;
        proxy_next_upstream error timeout http_404;
        proxy_pass          http://mirrorsewe$request_uri;
    }
    location @pkg_mirrorewe_reordered {
        proxy_store    on;
        proxy_redirect off;
        proxy_store_access  user:rw group:rw all:r;
        proxy_next_upstream error timeout http_404;
        proxy_pass          http://mirrorsewe/archlinuxewe/os/$1/$2;
    }

}

# other local mirrors
upstream caches {
    server 1.arch.eckner.net:80;
}

# Upstream Arch Linux Mirrors
# - Configure as many backend mirrors as you want in the blocks below
# - Servers are used in a round-robin fashion by nginx
# - Add "backup" if you want to only use the mirror upon failure of the other mirrors
# - Use separate mirror server blocks to be able to use mirrors that have different paths to the package repos
upstream mirrors {
    server 127.0.0.42:8001;
    server 127.0.0.42:8002;
    server 127.0.0.42:8003;
    server 127.0.0.42:8004;
}
upstream mirrors32 {
    server 127.0.0.43:8001;
}
upstream mirrorsarm {
    server 127.0.0.44:8001;
}
upstream mirrorsewe {
    server 127.0.0.45:8001;
}

# If you want to use an official mirror from /etc/pacman.d/mirrorlist like
# http://mirror.domain.example/path/to/repo/$repo/os/$arch
#
# the proxy_pass directive should look like this
# proxy_pass http://mirror.domain.example/path/to/repo$request_uri;
#
# Notice that $request_uri replaces the /$repo/os/$arch part of
# the mirror address. See more examples below.

server {
    listen      127.0.0.42:8001;
    location / {
        proxy_pass       https://ftp.gwdg.de/pub/linux/archlinux$request_uri;
    }
}

server {
    listen      127.0.0.42:8002;
    location / {
        proxy_pass       https://mirror.f4st.host/archlinux$request_uri;
    }
}

server {
    listen      127.0.0.42:8003;
    location / {
        proxy_pass       https://ftp.spline.inf.fu-berlin.de/mirrors/archlinux$request_uri;
    }
}

server {
    listen      127.0.0.42:8004;
    location / {
        proxy_pass       https://mirror.pkgbuild.com$request_uri;
    }
}

server {
    listen      127.0.0.43:8001;
    location / {
        proxy_pass       https://mirror.archlinux32.org$request_uri;
    }
}

server {
    listen      127.0.0.44:8001;
    location / {
        proxy_pass       http://mirror.archlinuxarm.org$request_uri;
    }
}

server {
    listen      127.0.0.45:8001;
    location / {
        proxy_pass       https://arch.eckner.net$request_uri;
    }
}