summaryrefslogtreecommitdiffstats
path: root/hosts/jenkins/etc/apache2/sites-available/jenkins.debian.net.conf
blob: 4f01a07530f7b681ef5276bd629b6a6e8d6bbd78 (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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
NameVirtualHost *:80
NameVirtualHost *:443

<Macro localhost-directives $ipaddress>
	<VirtualHost $ipaddress:80>
		ServerName $ipaddress
		ServerAdmin holger@layer-acht.org
		CustomLog /var/log/apache2/access.log combined
		ErrorLog /var/log/apache2/error.log
		<Proxy *>
			Require all granted
		</Proxy>
		ProxyPreserveHost on
		AllowEncodedSlashes NoDecode
		# proxy everything but a few urls
		ProxyPass /server-status !
		# map /d-i-preseed-cfgs to /UserContent/d-i-preseed-cfgs
		ProxyPass /d-i-preseed-cfgs/ http://localhost:8080/userContent/d-i-preseed-cfgs/
		ProxyPass /userContent !
		ProxyPass /cli !
		ProxyPass / http://localhost:8080/ nocanon
		ProxyPassReverse  / http://localhost:8080/
	</VirtualHost>
</Macro>

<Macro common-debian-service-https-redirect $name>
	<VirtualHost *:80>
		ServerName $name
		ServerAdmin holger@layer-acht.org
		CustomLog /var/log/apache2/access.log combined
		ErrorLog /var/log/apache2/error.log
		Redirect permanent / https://$name/
	</VirtualHost>
</Macro>

<Macro common-directives-ssl-chain $chainfile>
	SSLEngine on
	SSLCertificateChainFile /etc/apache2/ssl/$chainfile
</Macro>

<Macro common-directives-ssl-key $keyfile>
	SSLEngine on
	SSLCertificateKeyFile /etc/apache2/ssl/$keyfile
</Macro>

<Macro common-directives $name>
	ServerName $name
	ServerAdmin holger@layer-acht.org

	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Require all granted
		AddType text/plain .log
	</Directory>
	<Directory /var/lib/jenkins/userContent>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Require all granted
		AddType text/plain .log
	</Directory>

	<FilesMatch "\.gz$">
		AddEncoding gzip .gz
		ForceType text/plain
		FilterDeclare gzipInflate CONTENT_SET
		<IfVersion >= 2.4>
			FilterProvider gzipInflate inflate "%{req:Accept-Encoding} !~ /gzip/"
		</IfVersion>
		<IfVersion < 2.4>
			FilterProvider gzipInflate inflate req=Accept-Encoding !$gzip
		</IfVersion>
		FilterChain +gzipInflate
	</FilesMatch>

	RewriteEngine on
	ProxyRequests Off

	# HSTS
	RequestHeader set X-Forwarded-Proto "https"
	RequestHeader set X-Forwarded-Port "443"
	Header always add Strict-Transport-Security "max-age=15552000"

	ErrorLog ${APACHE_LOG_DIR}/error.log
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</Macro>

Use localhost-directives 127.0.0.1
Use localhost-directives 10.0.2.1

Use common-debian-service-https-redirect jenkins.debian.net
Use common-debian-service-https-redirect reproducible.debian.net
Use common-debian-service-https-redirect tests.reproducible-builds.org
Use common-debian-service-https-redirect reproducible-builds.org

<VirtualHost *:443>
	Use common-directives jenkins.debian.net
	Use common-directives-ssl-key jenkins.debian.net.key
	SSLCertificateFile /etc/apache2/ssl/jenkins.debian.net.pem

	DocumentRoot /var/www
	AddDefaultCharset utf-8

	# allow certain params only from alioth (token is used to trigger builds)
	RewriteCond %{REMOTE_ADDR} !5\.153\.231\.21
	# this is git.d.o which is really moszumanska.d.o
	# etc/cron.daily/jenkins checks for changes in this IP address, so root will be notified and can adopt this...
	RewriteCond %{QUERY_STRING} token
	RewriteRule ^ - [F]

	# a bunch of redirects to point people to https://reproducible.debian.net
	RewriteCond %{HTTP_HOST} jenkins\.debian\.net
	RewriteCond %{REQUEST_URI} ^/userContent/reproducible.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/reproducible.json$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_issues.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_notes.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_schedule.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_last_24h.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_last_48h.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_all_abc.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_dd-list.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_stats.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_pkg_sets.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_reproducible.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_FTBR_with_buildinfo.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_FTBR.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_FTBFS.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_404.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_not_for_us.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/index_blacklisted.html$ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/rb-pkg/ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/buildinfo/ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/dbd/ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/issues/ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/notes/ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/artifacts/ [or]
	RewriteCond %{REQUEST_URI} ^/userContent/rbuild/
	RewriteRule ^/?(.*) https://reproducible.debian.net/debian/$1 [R=301,L]

	<Proxy *>
		Require all granted
	</Proxy>
	ProxyPreserveHost on
	AllowEncodedSlashes NoDecode
	# proxy everything but a few urls
	ProxyPass /munin !
	ProxyPass /munin-cgi !
	ProxyPass /server-status !
	ProxyPass /calamaris !
	ProxyPass /robots.txt http://localhost:8080/userContent/robots.txt
	# map /d-i-preseed-cfgs to /UserContent/d-i-preseed-cfgs
	ProxyPass /d-i-preseed-cfgs/ http://localhost:8080/userContent/d-i-preseed-cfgs/
	ProxyPass /userContent !
	ProxyPass /cli !
	ProxyPass / http://localhost:8080/ nocanon
	ProxyPassReverse  / http://localhost:8080/
</VirtualHost>


<VirtualHost *:443>
	Use common-directives reproducible.debian.net
	Use common-directives-ssl-key reproducible.debian.net.key
	SSLCertificateFile /etc/apache2/ssl/reproducible.debian.net.pem

	DocumentRoot /var/lib/jenkins/userContent/reproducible
	AddDefaultCharset utf-8

	<Directory /var/lib/jenkins/userContent/reproducible/artifacts>
		HeaderName .HEADER.html
	</Directory>

	# use reproducible.html as "home page"
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/$
	RewriteRule ^/(.*) https://tests.reproducible-builds.org/debian/reproducible.html [R,L]

	# drop the (old|ugly) /userContent/ directory from the url
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_URI} ^/userContent
	RewriteRule ^/userContent/(.*)$ https://tests.reproducible-builds.org/$1 [R=301,L]

	# redirect rb.d.n/issues/$ISSUE → rb.d.n/debian/issues/unstable/$ISSUE
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/issues/unstable/$1 -f
	RewriteRule ^/issues/([a-z0-9.+-_]+) https://tests.reproducible-builds.org/debian/issues/unstable/$1 [R=302,L]

	# redirect rb.d.n/$PKG → rb.d.n/debian/rb-pkg/unstable/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/unstable/amd64/$1.html -f
	RewriteRule ^/([a-z0-9.+-]+) https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/$1.html [R=302,L]

	# redirect rb.d.n/redirect/?SrcPkg=$PKG → rb.d.n/rb-pkg/unstable/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{QUERY_STRING} ^(\w+)=([a-z0-9.+-]+)$
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/unstable/amd64/%2.html -f
	RewriteRule ^/redirect https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/%2.html? [R=302,L]

	# the following two rules are fallbacks for the previous two redirects and should only catch packages which are only in experimental

	# redirect rb.d.n/$PKG → rb.d.n/debian/rb-pkg/experimental/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/experimental/amd64/$1.html -f
	RewriteRule ^/([a-z0-9.+-]+) https://tests.reproducible-builds.org/debian/rb-pkg/experimental/amd64/$1.html [R=302,L]

	# redirect rb.d.n/redirect/?SrcPkg=$PKG → rb.d.n/debian/rb-pkg/experimental/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{QUERY_STRING} ^(\w+)=([a-z0-9.+-]+)$
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/experimental/amd64/%2.html -f
	RewriteRule ^/redirect https://tests.reproducible-builds.org/debian/rb-pkg/experimental/amd64/%2.html? [R=302,L]

	# redirect rb.d.n/$suite/(amd64|armhf|i386)/$PKG → rb.d.n/rb-pkg/$suite/$arch/$PKG.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/$1/$2/$3.html -f
	RewriteRule ^/(unstable|testing|experimental)/([a-z0-9]+)/([a-z0-9.+-]+) https://tests.reproducible-builds.org/debian/rb-pkg/$1/$2/$3.html [R=302,L]

	# redirect rb.d.n/rb-pkg/$PKG.html → rb.d.n/debian/rb-pkg/unstable/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/unstable/amd64/$1 -f
	RewriteRule ^/rb-pkg/([a-z0-9.+-]+) https://tests.reproducible-builds.org/debian/rb-pkg/unstable/amd64/$1 [R=301,L]
	# the same for /dbd/
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/dbd/unstable/amd64/$1 -f
	RewriteRule ^/dbd/([a-z0-9.+-_]+) https://tests.reproducible-builds.org/debian/dbd/unstable/amd64/$1 [R=301,L]
	# the same for /rbuild/
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rbuild/unstable/amd64/$1 -f
	RewriteRule ^/rbuild/([a-z0-9.+-_]+) https://tests.reproducible-builds.org/debian/rbuild/unstable/amd64/$1 [R=301,L]
	# the same for /buildinfo/
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/buildinfo/unstable/amd64/$1 -f
	RewriteRule ^/buildinfo/([a-z0-9.+-_]+) https://tests.reproducible-builds.org/debian/buildinfo/unstable/amd64/$1 [R=301,L]
	# redirect some rb.d.n/index_*.html to the suite/arch relative one
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_URI} ^/index_reproducible.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_FTBR.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_FTBFS.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_depwait.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_404.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_not_for_us.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_blacklisted.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_last_24h.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_last_48h.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_all_abc.html$
	RewriteRule ^/?(.+) https://tests.reproducible-builds.org/debian/unstable/amd64/$1 [R=301,L]

	# redirect (/testing|unstable|/experimental) to (/testing|/unstable|/experimental)/index_suite_amd64_stats.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/(testing|unstable|experimental)(/|)$
	RewriteRule ^/(.*) https://tests.reproducible-builds.org/debian/$1/index_suite_amd64_stats.html [R,L]

	# redirect (/testing|unstable|/experimental)/(amd64|armhf|i386) to (/testing|/unstable|/experimental)/index_suite_(amd64|armhf|i386)_stats.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/(testing|unstable|experimental)/(amd64|armhf|i386)(/|)$
	RewriteRule ^/([a-z0-9]+)/([a-z0-9]+) https://tests.reproducible-builds.org/debian/$1/index_suite_$2_stats.html [R,L]

	# redirect (/(amd64|armhf|i386) to (/testing|/unstable|/experimental)/index_suite_(amd64|armhf|i386)_stats.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/(amd64|armhf|i386)(/|)$
	RewriteRule ^/([a-z0-9]+) https://tests.reproducible-builds.org/debian/unstable/index_suite_$1_stats.html [R,L]

	# redirect /coreboot/ to coreboot/coreboot.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/coreboot(/|)$
	RewriteRule ^/(.*) https://tests.reproducible-builds.org/coreboot/coreboot.html [R,L]

	# redirect /openwrt/ to openwrt/openwrt.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/openwrt(/|)$
	RewriteRule ^/(.*) https://tests.reproducible-builds.org/openwrt/openwrt.html [R,L]

	# redirect /netbsd/ to netbsd/netbsd.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/netbsd(/|)$
	RewriteRule ^/(.*) https://tests.reproducible-builds.org/netbsd/netbsd.html [R,L]

	# redirect /freebsd/ to freebsd/freebsd.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/freebsd(/|)$
	RewriteRule ^/(.*) https://tests.reproducible-builds.org/freebsd/freebsd.html [R,L]

	# redirect /archlinux/ to archlinux/archlinux.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/archlinux(/|)$
	RewriteRule ^/(.*) https://tests.reproducible-builds.org/archlinux/archlinux.html [R,L]

	# redirect /issues/ to /index_issues.html
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/issues(/|)$
	RewriteRule ^/(.*) https://tests.reproducible-builds.org/index_issues.html [R,L]

	# redirect /fedora properly…
	RewriteCond %{HTTP_HOST} reproducible\.debian\.net
	RewriteCond %{REQUEST_URI} ^/fedora(/|)$
	RewriteRule ^/?(.*) https://tests.reproducible-builds.org/rpms/fedora-23.html [R,L]

	<Proxy *>
		Require all granted
	</Proxy>

</VirtualHost>

<VirtualHost *:443>
	Use common-directives tests.reproducible-builds.org
	Use common-directives-ssl-key reproducible.debian.net.key
	SSLCertificateFile /etc/apache2/ssl/reproducible.debian.net.pem

	DocumentRoot /var/lib/jenkins/userContent/reproducible
	AddDefaultCharset utf-8

	<Directory /var/lib/jenkins/userContent/reproducible/artifacts>
		HeaderName .HEADER.html
	</Directory>

	# use reproducible.html as "home page"
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/$
	RewriteRule ^/(.*) /debian/reproducible.html [R,L]

	# drop the (old|ugly) /userContent/ directory from the url
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_URI} ^/userContent
	RewriteRule ^/userContent/(.*)$ /$1 [R=301,L]

	# redirect rb.d.n/issues/$ISSUE → rb.d.n/issues/unstable/$ISSUE
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/issues/unstable/$1 -f
	RewriteRule ^/issues/([a-z0-9.+-_]+) /debian/issues/unstable/$1 [R=302,L]

	# redirect rb.d.n/$PKG → rb.d.n/rb-pkg/unstable/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/unstable/amd64/$1.html -f
	RewriteRule ^/([a-z0-9.+-]+) /debian/rb-pkg/unstable/amd64/$1.html [R=302,L]

	# redirect rb.d.n/redirect/?SrcPkg=$PKG → rb.d.n/rb-pkg/unstable/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{QUERY_STRING} ^(\w+)=([a-z0-9.+-]+)$
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/unstable/amd64/%2.html -f
	RewriteRule ^/redirect /debian/rb-pkg/unstable/amd64/%2.html? [R=302,L]

	# the following two rules are fallbacks for the previous two redirects and should only catch packages which are only in experimental

	# redirect rb.d.n/$PKG → rb.d.n/rb-pkg/experimental/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/experimental/amd64/$1.html -f
	RewriteRule ^/([a-z0-9.+-]+) /debian/rb-pkg/experimental/amd64/$1.html [R=302,L]

	# redirect rb.d.n/redirect/?SrcPkg=$PKG → rb.d.n/rb-pkg/experimental/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{QUERY_STRING} ^(\w+)=([a-z0-9.+-]+)$
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/experimental/amd64/%2.html -f
	RewriteRule ^/redirect /debian/rb-pkg/experimental/amd64/%2.html? [R=302,L]

	# redirect rb.d.n/$suite/(amd64|armhf|i386)/$PKG → rb.d.n/rb-pkg/$suite/$arch/$PKG.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/$1/$2/$3.html -f
	RewriteRule ^/(unstable|testing|experimental)/([a-z0-9]+)/([a-z0-9.+-]+) /debian/rb-pkg/$1/$2/$3.html [R=302,L]

	# redirect rb.d.n/rb-pkg/$PKG.html → rb.d.n/rb-pkg/unstable/amd64/$PKG.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rb-pkg/unstable/amd64/$1 -f
	RewriteRule ^/rb-pkg/([a-z0-9.+-]+) /debian/rb-pkg/unstable/amd64/$1 [R=301,L]
	# the same for /dbd/
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/dbd/unstable/amd64/$1 -f
	RewriteRule ^/dbd/([a-z0-9.+-_]+) /debian/dbd/unstable/amd64/$1 [R=301,L]
	# the same for /rbuild/
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/rbuild/unstable/amd64/$1 -f
	RewriteRule ^/rbuild/([a-z0-9.+-_]+) /debian/rbuild/unstable/amd64/$1 [R=301,L]
	# the same for /buildinfo/
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond /var/lib/jenkins/userContent/reproducible/debian/buildinfo/unstable/amd64/$1 -f
	RewriteRule ^/buildinfo/([a-z0-9.+-_]+) /debian/buildinfo/unstable/amd64/$1 [R=301,L]
	# redirect some rb.d.n/index_*.html to the suite/arch relative one
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_FILENAME} !-f
	RewriteCond %{REQUEST_FILENAME} !-d
	RewriteCond %{REQUEST_URI} ^/index_reproducible.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_FTBR.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_FTBFS.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_depwait.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_404.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_not_for_us.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_blacklisted.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_last_24h.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_last_48h.html$ [or]
	RewriteCond %{REQUEST_URI} ^/index_all_abc.html$
	RewriteRule ^/?(.+) /debian/unstable/amd64/$1 [R=301,L]

	# redirect (/testing|unstable|/experimental) to (/testing|/unstable|/experimental)/index_suite_amd64_stats.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/(testing|unstable|experimental)(/|)$
	RewriteRule ^/(.*) /debian/$1/index_suite_amd64_stats.html [R,L]

	# redirect (/testing|unstable|/experimental)/(amd64|armhf|i386) to (/testing|/unstable|/experimental)/index_suite_(amd64|armhf|i386)_stats.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/(testing|unstable|experimental)/(amd64|armhf|i386)(/|)$
	RewriteRule ^/([a-z0-9]+)/([a-z0-9]+) /debian/$1/index_suite_$2_stats.html [R,L]

	# redirect (/(amd64|armhf|i386) to (/testing|/unstable|/experimental)/index_suite_(amd64|armhf|i386)_stats.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/(amd64|armhf|i386)(/|)$
	RewriteRule ^/([a-z0-9]+) /debian/unstable/index_suite_$1_stats.html [R,L]

	# redirect /coreboot/ to coreboot/coreboot.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/coreboot(/|)$
	RewriteRule ^/(.*) /coreboot/coreboot.html [R,L]

	# redirect /openwrt/ to openwrt/openwrt.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/openwrt(/|)$
	RewriteRule ^/(.*) /openwrt/openwrt.html [R,L]

	# redirect /netbsd/ to netbsd/netbsd.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/netbsd(/|)$
	RewriteRule ^/(.*) /netbsd/netbsd.html [R,L]

	# redirect /freebsd/ to freebsd/freebsd.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/freebsd(/|)$
	RewriteRule ^/(.*) /freebsd/freebsd.html [R,L]

	# redirect /archlinux/ to archlinux/archlinux.html
	# note: the missing slash in the RewriteRule is wanted to avoid a double slash
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/archlinux(/|)$
	RewriteRule ^/(.*) /archlinux/archlinux.html [R,L]

	# redirect /fedora/ properly…
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/fedora(/|)$
	RewriteRule ^/?(.*) /rpms/fedora-23.html [R,L]

	# redirect /issues/ to /index_issues.html
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/issues(/|)$
	RewriteRule ^/(.*) /debian/index_issues.html [R,L]

	# temporary redirect until the html is rewritten
	RewriteCond %{HTTP_HOST} tests\.reproducible-builds\.org
	RewriteCond %{REQUEST_URI} ^/debian(/|)$
	RewriteRule ^/?(.*) /debian/reproducible.html [R,L]

	<Proxy *>
		Require all granted
	</Proxy>

</VirtualHost>


<VirtualHost *:443>
	Use common-directives reproducible-builds.org
	Use common-directives-ssl-chain startcom.crt
	SSLCertificateFile /etc/apache2/ssl/reproducible-builds.org.pem

	DocumentRoot /srv/reproducible-builds.org/www
	AddDefaultCharset utf-8

	Alias /website.git /srv/reproducible-builds.org/git/website.git
	Alias /specs /var/lib/jenkins/userContent/reproducible/specs

	RewriteEngine on
	RewriteRule /howto($|/.*) /docs/ [R=permanent]

	<Directory /srv/reproducible-builds.org/www>
		AllowOverride None
		Require all granted
	</Directory>
	<Directory /srv/reproducible-builds.org/git>
		Options Indexes
		AllowOverride None
		Require all granted
	</Directory>
</VirtualHost>