15199353eab5087d6537225da7103552d7f7e01d
[mirror/dsa-puppet.git] / modules / roles / templates / static-mirroring / vhost / static-vhosts-simple.erb
1 # puppet maintained
2
3 ######################
4 # deb.debian.org
5 <% if scope.function_has_static_component(['deb.debian.org']) -%>
6 <Macro vstatic-vhost-extra-deb.debian.org>
7         ServerAlias httpredir.debian.org
8         ServerAlias cdn.debian.net
9         ServerAlias http.debian.net
10
11         Redirect /debian            http://cdn-fastly.deb.debian.org/debian
12         Redirect /debian-debug      http://cdn-fastly.deb.debian.org/debian-debug
13         Redirect /debian-ports      http://cdn-fastly.deb.debian.org/debian-ports
14         Redirect /debian-security   http://cdn-fastly.deb.debian.org/debian-security
15 </Macro>
16
17 <VirtualHost <%= @vhost_listen_443 %> >
18         ServerName deb.debian.org
19
20         ErrorLog /var/log/apache2/deb.debian.org-error.log
21         CustomLog /var/log/apache2/deb.debian.org-access.log privacyssl
22
23         Use common-debian-service-ssl deb.debian.org
24         Use common-ssl-HSTS
25
26         ServerAdmin debian-admin@lists.debian.org
27         <IfModule mod_userdir.c>
28                 UserDir disabled
29         </IfModule>
30         ServerSignature On
31
32         DocumentRoot /srv/static.debian.org/mirrors/deb.debian.org/cur
33         <Directory /srv/static.debian.org/mirrors/deb.debian.org/cur>
34                 AllowOverride FileInfo Indexes Options=Multiviews
35                 Options Indexes SymLinksIfOwnerMatch
36                 Require all granted
37         </Directory>
38
39         Header set Surrogate-Key <%= @hostname %>
40
41         AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
42
43         Redirect /debian            https://cdn-aws.deb.debian.org/debian
44         Redirect /debian-debug      https://cdn-aws.deb.debian.org/debian-debug
45         Redirect /debian-ports      https://cdn-aws.deb.debian.org/debian-ports
46         Redirect /debian-security   https://cdn-aws.deb.debian.org/debian-security
47 </VirtualHost>
48 <% end -%>
49
50 <Macro vstatic-vhost-extra-network-test.debian.org>
51         ServerAlias network-test-backend.debian.org
52         <Location /nm>
53                 Header set Cache-Control "must-revalidate, max-age=0"
54         </Location>
55 </Macro>
56
57 <Macro vstatic-vhost-extra-bits.debian.org>
58         <IfModule mod_geoip.c>
59                 CustomLog /var/log/apache2/bits.debian.org-public-access.log privacy+geo
60         </IfModule>
61 </Macro>
62
63 <Macro vstatic-vhost-extra-metadata.ftp-master.debian.org>
64         AddDefaultCharset utf-8
65
66         # Rewrite away double slashes
67         RewriteEngine on
68         RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ [NC]
69         RewriteRule . %1/%2 [R=301,L,NE]
70
71         <LocationMatch "/changelogs/(main|contrib|non-free)">
72                 ForceType text/plain
73         </LocationMatch>
74 </Macro>
75
76 <Macro vstatic-vhost-extra-release.debian.org>
77         RewriteEngine   on
78         RewriteRule             ^/migration/$                   /migration/testing.pl
79         RewriteRule             ^/migration/search/(.+)/$       /migration/testing.pl?package=$1
80         RewriteCond             %{QUERY_STRING} package=((.)(.*))
81         RewriteRule             ^/migration/testing.pl          /migration/cache/%2/%1.html [PT,L]
82         RewriteRule             ^/migration/testing.pl          /migration/cache/_index.html
83
84         Alias /oldstable-proposed-updates/ /srv/static.debian.org/mirrors/release.debian.org-pu/cur/
85         Alias /proposed-updates/ /srv/static.debian.org/mirrors/release.debian.org-pu/cur/
86         <Directory /srv/static.debian.org/mirrors/release.debian.org-pu/cur>
87                 Require all granted
88                 Options Indexes SymLinksIfOwnerMatch MultiViews
89
90                 AddEncoding gzip .gz
91                 FilterDeclare gzip CONTENT_SET
92                 FilterProvider gzip inflate "%{req:Accept-Encoding} !~ /gzip/"
93                 FilterChain gzip
94                 <Files *.debdiff.gz>
95                         ForceType text/plain
96                         AddDefaultCharset utf-8
97                 </Files>
98                 <Files *.debdiff.html.gz>
99                         ForceType text/html
100                         AddDefaultCharset utf-8
101                 </Files>
102         </Directory>
103 </Macro>
104
105 <Macro vstatic-vhost-extra-www.ports.debian.org>
106         <Directory /srv/static.debian.org/mirrors/www.ports.debian.org/cur>
107                 AllowOverride FileInfo Indexes Options=Multiviews
108                 Options Multiviews Indexes FollowSymLinks Includes
109                 Require all granted
110         </Directory>
111
112         AddOutputFilter INCLUDES .xhtml
113 </Macro>
114
115
116 <Macro vstatic-vhost-extra-lintian.debian.org>
117         AddDefaultCharset utf-8
118
119         <Directory /srv/static.debian.org/mirrors/lintian.debian.org/cur>
120                 Require all granted
121
122                 # These three lines makes apache serve
123                 # "lintian.log.gz" as a text/plain with encoding gzip
124                 # making it easier to view the log in the browser.
125                 RemoveType .gz
126                 AddEncoding x-gzip .gz
127                 AddType text/plain .log
128
129                 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css image/svg+xml
130         </Directory>
131
132         <Directory /srv/static.debian.org/mirrors/lintian.debian.org/cur/resources>
133                 # Cache these for a year (3600 * 24 * 365.25)
134                 # Files in here will change name if their content change
135                 Header set Cache-Control "max-age=31557600, public"
136         </Directory>
137
138         RewriteEngine on
139         RewriteMap source-map txt:/srv/static.debian.org/mirrors/lintian.debian.org/cur/lookup-tables/source-packages
140
141         # Re-direct from the "old" locations to the new ones
142         RewriteRule ^/reports/T(.*)\.html$ /tags/$1.html [L,R=permanent]
143         RewriteRule ^/reports/(.*)$ /$1 [L,R=permanent]
144
145         # Map source packages to reports (this mapping is re-written once per lintian run,
146         # serve it as a 302 rather than a permanent redirect)
147         # Version-less request
148         RewriteRule ^/source/([a-z0-9-]+)/?$ /${source-map:$1} [L,R,NE]
149         # Versioned request
150         RewriteRule ^/source/([a-z0-9-]+)/([a-zA-Z0-9.+:~-]+)$ /${source-map:$1/$2} [L,R,NE]
151
152         Header always set Content-Security-Policy "default-src 'self'; media-src 'none'; object-src 'none';"
153         <FilesMatch "\.(svg)$">
154                 Header always set Content-Security-Policy "default-src 'none'; frame-ancestors 'none'; style-src 'self' 'unsafe-inline';"
155         </FilesMatch>
156 </Macro>
157
158 <Macro vstatic-vhost-extra-wiki.debconf.org>
159         <Location /wiki/>
160                 ForceType text/html
161         </Location>
162         <Location /action/>
163                 ForceType text/html
164         </Location>
165
166         RewriteEngine on
167         RewriteRule ^/$ /wiki/Main_Page [L,R=permanent]
168         RewriteRule ^/wiki/$ /wiki/Main_Page [L,R=permanent]
169
170         RewriteCond %{QUERY_STRING} (^|&)modules=mediawiki.legacy.commonPrint,shared|skins.monobook(&|$)
171         RewriteCond %{QUERY_STRING} (^|&)only=styles(&|$)
172         RewriteRule ^/load.php$ /load-monobook-styles.css [L,QSD]
173
174         RewriteCond %{QUERY_STRING} (^|&)modules=site(&|$)
175         RewriteCond %{QUERY_STRING} (^|&)only=styles(&|$)
176         RewriteRule ^/load.php$ /load-site-styles.css [L,QSD]
177
178         RewriteCond %{QUERY_STRING} (^|&)modules=startup(&|$)
179         RewriteCond %{QUERY_STRING} (^|&)only=scripts(&|$)
180         RewriteRule ^/load.php$ /load-startup-scripts.js [L,QSD]
181
182         RewriteCond %{QUERY_STRING} (^|&)modules=site(&|$)
183         RewriteCond %{QUERY_STRING} (^|&)only=scripts(&|$)
184         RewriteRule ^/load.php$ /load-site-scripts.js [L,QSD]
185
186         RewriteCond %{QUERY_STRING} (^|&)modules=jquery%2Cmediawiki(&|$)
187         RewriteCond %{QUERY_STRING} (^|&)only=scripts(&|$)
188         RewriteRule ^/load.php$ /load-jquery-scripts.js [L,QSD]
189
190         RewriteCond %{QUERY_STRING} (^|&)modules=jquery.client%2Ccookie%2CmessageBox%2CmwExtension|mediawiki.legacy.ajax%2Cwikibits|mediawiki.page.startup|mediawiki.util(&|$)
191         RewriteRule ^/load.php$ /load-jquery.client.js [L,QSD]
192
193         RewriteCond %{QUERY_STRING} (^|&)modules=jquery.checkboxShiftClick%2CmakeCollapsible%2Cmw-jump%2Cplaceholder%7Cmediawiki.page.ready%7Cmediawiki.user(&|$)
194         RewriteRule ^/load.php$ /load-jquery.checkbox.js [L,QSD]
195 </Macro>
196
197 <Macro vstatic-vhost-extra-www.debconf.org>
198         ServerAlias www-test.debconf.org
199
200         <Directory /srv/static.debian.org/mirrors/www.debconf.org/cur>
201                 Options +Includes
202         </Directory>
203
204         AddOutputFilter INCLUDES .shtml
205 </Macro>
206
207 <%=
208
209 def vhost(lines, sn, kwargs={})
210         if scope.function_has_static_component([sn])
211                 if not kwargs[:extra]
212                                 lines << "<Macro vstatic-vhost-extra-#{sn}>"
213                                 lines << "  # mod macro does not like empty macros, so here's some content:"
214                                 lines << "  <Directory /non-existant>"
215                                 lines << "  </Directory>"
216                                 lines << "</Macro>"
217                 end
218
219                 lines << "Use prepare-static-vhost #{sn}"
220
221                 if kwargs[:ssl] and kwargs[:ssl_optional]
222                         lines << "Use static-vhost-plain-#{sn}"
223                         lines << "Use static-vhost-ssl-#{sn}"
224                 elsif kwargs[:ssl]
225                         lines << "Use common-dsa-vhost-https-redirect #{sn}"
226                         lines << "Use static-vhost-ssl-#{sn}"
227                 else
228                         lines << "Use static-vhost-plain-#{sn}"
229                 end
230
231                 onion = scope.function_onion_global_service_hostname([sn])
232                 lines << "Use static-vhost-onion-#{sn} #{onion}" if onion
233
234                 lines << ""
235         end
236 end
237
238 lines = []
239 vhost(lines, "mozilla.debian.net"            , :ssl => true, :ssl_optional => true)
240 vhost(lines, "backports.debian.org"          , :ssl => true)
241 vhost(lines, "incoming.debian.org"           , :ssl => true, :ssl_optional => true)
242 vhost(lines, "incoming.ports.debian.org"     , :ssl => true, :ssl_optional => true)
243 vhost(lines, "debdeltas.debian.net"          , :ssl => true, :ssl_optional => true)
244 vhost(lines, "news.debian.net"               , :ssl => true)
245 vhost(lines, "bootstrap.debian.net"          , :ssl => true)
246 vhost(lines, "debaday.debian.net"            , :ssl => true)
247 vhost(lines, "timeline.debian.net"           , :ssl => true)
248 vhost(lines, "network-test.debian.org"       , :extra => true)
249 vhost(lines, "blends.debian.org"             , :ssl => true)
250 vhost(lines, "wnpp-by-tags.debian.net"       , :ssl => true)
251 vhost(lines, "security-team.debian.org"      , :ssl => true)
252 vhost(lines, "d-i.debian.org"                , :ssl => true)
253 vhost(lines, "appstream.debian.org"          , :ssl => true)
254 vhost(lines, "apt.buildd.debian.org"         , :ssl => true)
255 vhost(lines, "dpl.debian.org"                , :ssl => true)
256 vhost(lines, "dsa.debian.org"                , :ssl => true)
257 vhost(lines, "rtc.debian.org"                , :ssl => true)
258 vhost(lines, "mirror-master.debian.org"      , :ssl => true)
259 vhost(lines, "onion.debian.org"              , :ssl => true)
260 vhost(lines, "manpages.debian.org"           , :ssl => true, :extra => true)
261 vhost(lines, "cdbuilder-logs.debian.org"     , :ssl => true)
262
263 vhost(lines, "bits.debian.org"               , :ssl => true, :extra => true)
264 vhost(lines, "micronews.debian.org"          , :ssl => true)
265 vhost(lines, "metadata.ftp-master.debian.org", :extra => true)
266
267 vhost(lines, "10years.debconf.org"           , :ssl => true)
268 vhost(lines, "debconf0.debconf.org"          , :ssl => true)
269 vhost(lines, "debconf1.debconf.org"          , :ssl => true)
270 vhost(lines, "debconf2.debconf.org"          , :ssl => true)
271 vhost(lines, "debconf3.debconf.org"          , :ssl => true)
272 vhost(lines, "debconf4.debconf.org"          , :ssl => true)
273 vhost(lines, "debconf5.debconf.org"          , :ssl => true)
274 vhost(lines, "debconf6.debconf.org"          , :ssl => true)
275 vhost(lines, "debconf7.debconf.org"          , :ssl => true)
276 vhost(lines, "debconf16.debconf.org"         , :ssl => true)
277 vhost(lines, "debconf17.debconf.org"         , :ssl => true)
278 vhost(lines, "debconf18.debconf.org"         , :ssl => true)
279 vhost(lines, "debconf19.debconf.org"         , :ssl => true)
280 vhost(lines, "es.debconf.org"                , :ssl => true)
281 vhost(lines, "fr.debconf.org"                , :ssl => true)
282 vhost(lines, "miniconf10.debconf.org"        , :ssl => true)
283 vhost(lines, "wiki.debconf.org"              , :ssl => true, :extra => true)
284 vhost(lines, "www.debconf.org"               , :ssl => true, :extra => true)
285
286 vhost(lines, "deb.debian.org"                , :extra => true)
287 vhost(lines, "release.debian.org"            , :ssl => true, :extra => true)
288 vhost(lines, "www.ports.debian.org"          , :ssl => true, :extra => true)
289 vhost(lines, "lintian.debian.org"            , :ssl => true, :extra => true)
290
291 lines.join("\n")
292 -%>
293
294 # www.backports.org
295 ###################
296 # www.backports.org is the historical place for the backports
297 # website and archive.  It is now a CNAME to backports.debian.org:
298 # redirect http requests.
299 <VirtualHost <%= @vhost_listen %> >
300         ServerName www.backports.org
301         ServerAlias lists.backports.org
302         ServerAdmin debian-admin@debian.org
303         RedirectPermanent / https://backports.debian.org/
304 </VirtualHost>
305
306 ######################
307 <VirtualHost <%= @vhost_listen %> >
308         ServerName www.debian-ports.org
309         ServerAlias debian-ports.org
310         ServerAdmin debian-admin@debian.org
311         RedirectPermanent / https://www.ports.debian.org/
312 </VirtualHost>
313
314 <VirtualHost <%= @vhost_listen %> >
315         ServerName ports.debian.org
316         ServerAlias ports.debian.net
317         ServerAdmin debian-admin@debian.org
318         RedirectPermanent / https://www.ports.debian.org/
319 </VirtualHost>
320
321 <VirtualHost <%= @vhost_listen %> >
322         ServerName incoming.debian-ports.org
323         ServerAdmin debian-admin@debian.org
324         RedirectPermanent / http://incoming.ports.debian.org/
325 </VirtualHost>
326
327 <VirtualHost <%= @vhost_listen %> >
328         ServerName ftp.debian-ports.org
329         ServerAdmin debian-admin@debian.org
330         RedirectPermanent /archive https://www.ports.debian.org
331         RedirectPermanent /debian http://ftp.ports.debian.org/debian-ports
332         RedirectPermanent /debian-cd https://cdimage.debian.org/cdimage/ports/
333         RedirectPermanent / http://ftp.ports.debian.org/
334 </VirtualHost>
335
336 <Macro vstatic-vhost-video.debian.net>
337         ServerName video.debian.net
338         ServerAdmin debian-admin@debian.org
339         Redirect / https://meetings-archive.debian.net/pub/debian-meetings/
340 </Macro>
341
342 <VirtualHost <%= @vhost_listen %> >
343         Use vstatic-vhost-video.debian.net
344 </VirtualHost>
345
346 <VirtualHost <%= @vhost_listen_443 %> >
347         Use vstatic-vhost-video.debian.net
348         Use common-debian-service-ssl video.debian.net
349         Use common-ssl-HSTS
350 </VirtualHost>
351
352 Use common-dsa-vhost-https-redirect lists.alioth.debian.org
353 <VirtualHost <%= @vhost_listen_443 %> >
354         ServerName lists.alioth.debian.org
355         ServerAdmin debian-admin@debian.org
356         Use common-debian-service-ssl lists.alioth.debian.org
357         Use common-ssl-HSTS
358         Redirect / https://alioth-lists.debian.net/
359 </VirtualHost>
360
361 Use common-dsa-vhost-https-redirect pkg-ruby-extras.alioth.debian.org
362 <VirtualHost <%= @vhost_listen_443 %> >
363         ServerName pkg-ruby-extras.alioth.debian.org
364         ServerAdmin debian-admin@debian.org
365         Use common-debian-service-ssl pkg-ruby-extras.alioth.debian.org
366         Use common-ssl-HSTS
367         Redirect / https://gemwatch.debian.net/
368 </VirtualHost>
369
370 Use common-dsa-vhost-https-redirect video.debconf.org
371 <VirtualHost <%= @vhost_listen_443 %> >
372         ServerName video.debconf.org
373         ServerAdmin debian-admin@debian.org
374         Use common-debian-service-ssl video.debconf.org
375         Use common-ssl-HSTS
376         Redirect / https://debconf-video-team.pages.debian.net/docs/
377 </VirtualHost>
378
379 <% if scope.function_has_static_component(['metadata.ftp-master.debian.org']) -%>
380 <VirtualHost <%= @vhost_listen_443 %> >
381         ServerName metadata.ftp-master.debian.org
382         ServerAlias metadata-backend.ftp-master.debian.org
383         # all self-referential URLs should use the public host name
384         UseCanonicalName On
385         Use common-debian-service-ssl metadata-backend.ftp-master.debian.org
386         ErrorLog /var/log/apache2/metadata-backend.ftp-master.debian.org-error.log
387         CustomLog /var/log/apache2/metadata-backend.ftp-master.debian.org-access.log privacy
388
389         Use static-vhost-base-metadata.ftp-master.debian.org
390 </VirtualHost>
391 <% end -%>
392
393 # historical sites
394 ##################
395 # now only redirects remain
396 <VirtualHost <%= @vhost_listen %> >
397         ServerName women.debian.org
398         ServerAdmin debian-admin@debian.org
399
400         RedirectPermanent / https://www.debian.org/women/
401
402         RedirectPermanent /about/ https://www.debian.org/women/about
403         RedirectPermanent /contact/ https://www.debian.org/women/contact
404         RedirectPermanent /faqs/ https://www.debian.org/women/faq
405         RedirectPermanent /home/ https://www.debian.org/women/
406         RedirectPermanent /images/dw.png https://www.debian.org/women/dw.png
407         RedirectPermanent /involvement/ https://www.debian.org/women/participate
408         RedirectPermanent /mentoring/ https://www.debian.org/women/mentoring
409         RedirectPermanent /press/ https://wiki.debian.org/DebianWomen/Press
410         RedirectPermanent /profiles/ https://www.debian.org/women/profiles/
411 </VirtualHost>
412
413 <VirtualHost <%= @vhost_listen %> >
414         ServerName volatile.debian.org
415         ServerAlias volatile-master.debian.org
416         ServerAdmin debian-admin@debian.org
417         RedirectPermanent / https://www.debian.org/volatile/
418 </VirtualHost>
419
420 <VirtualHost <%= @vhost_listen %> >
421         ServerName ftp-master.metadata.debian.org
422         ServerAdmin debian-admin@debian.org
423         RedirectPermanent / http://metadata.ftp-master.debian.org/
424 </VirtualHost>
425
426 <VirtualHost <%= @vhost_listen %> >
427         ServerName backports-master.debian.org
428         ServerAdmin debian-admin@debian.org
429         RedirectPermanent / https://backports.debian.org/
430 </VirtualHost>
431
432 <VirtualHost <%= @vhost_listen %> >
433         ServerName manpages.debian.net
434         ServerAdmin debian-admin@debian.org
435         Redirect / https://manpages.debian.org/
436 </VirtualHost>
437
438 Use common-dsa-vhost-https-redirect sources.debian.net
439 <VirtualHost <%= @vhost_listen_443 %> >
440         ServerName sources.debian.net
441         ServerAdmin debian-admin@debian.org
442         Use common-debian-service-ssl sources.debian.net
443         Use common-ssl-HSTS
444         Redirect permanent / https://sources.debian.org/
445 </VirtualHost>
446
447 # error pages
448 #############
449
450 Use common-dsa-vhost-https-redirect archive.debian.net
451 <VirtualHost <%= @vhost_listen_443 %> >
452         ServerName archive.debian.net
453         ServerAdmin debian-admin@debian.org
454         ErrorLog /var/log/apache2/archive.debian.net-error.log
455         CustomLog /var/log/apache2/archive.debian.net-access.log privacyssl
456         Use common-debian-service-ssl archive.debian.net
457         Use common-ssl-HSTS
458         Use common-disabled-service
459 </VirtualHost>
460
461 <VirtualHost <%= @vhost_listen %> >
462         ServerName cdimage.debian.org
463         ServerAlias cloud.debian.org
464         ServerAlias get.debian.org
465         ServerAlias bttracker.debian.org
466         ServerAlias meetings-archive.debian.net
467         ServerAdmin debian-admin@debian.org
468         ErrorLog /var/log/apache2/cdimage.debian.org-error.log
469         CustomLog /var/log/apache2/cdimage.debian.org-access.log privacyssl
470
471         <IfModule mod_userdir.c>
472                 UserDir disabled
473         </IfModule>
474         DocumentRoot /srv/static.debian.org/puppet/cdimage.debian.org
475         <Directory /srv/static.debian.org/puppet/cdimage.debian.org>
476                 Require all granted
477         </Directory>
478         RewriteEngine On
479         RewriteRule !^/503.html / [R=503]
480         ErrorDocument 503 /503.html
481 </VirtualHost>
482
483 <VirtualHost <%= @vhost_listen_443 %> >
484         ServerName cdimage.debian.org
485         ServerAlias cloud.debian.org
486         ServerAlias get.debian.org
487         ServerAlias bttracker.debian.org
488         ServerAlias meetings-archive.debian.net
489         ServerAdmin debian-admin@debian.org
490         ErrorLog /var/log/apache2/cdimage.debian.org-error.log
491         CustomLog /var/log/apache2/cdimage.debian.org-access.log privacyssl
492         Use common-debian-service-ssl cdimage.debian.org
493
494         <IfModule mod_userdir.c>
495                 UserDir disabled
496         </IfModule>
497         DocumentRoot /srv/static.debian.org/puppet/cdimage.debian.org
498         <Directory /srv/static.debian.org/puppet/cdimage.debian.org>
499                 Require all granted
500         </Directory>
501         RewriteEngine On
502         RewriteRule !^/503.html / [R=503]
503         ErrorDocument 503 /503.html
504 </VirtualHost>
505
506
507 # vim:ft=apache: