0af5e2ab3f235e29d4549ef37c97e85520ad8420
[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-metadata-backend.ftp-master.debian.org>
77         Use vstatic-vhost-extra-metadata.ftp-master.debian.org>
78 </Macro>
79
80 <Macro vstatic-vhost-extra-release.debian.org>
81         RewriteEngine   on
82         RewriteRule             ^/migration/$                   /migration/testing.pl
83         RewriteRule             ^/migration/search/(.+)/$       /migration/testing.pl?package=$1
84         RewriteCond             %{QUERY_STRING} package=((.)(.*))
85         RewriteRule             ^/migration/testing.pl          /migration/cache/%2/%1.html [PT,L]
86         RewriteRule             ^/migration/testing.pl          /migration/cache/_index.html
87
88         Alias /oldstable-proposed-updates/ /srv/static.debian.org/mirrors/release.debian.org-pu/cur/
89         Alias /proposed-updates/ /srv/static.debian.org/mirrors/release.debian.org-pu/cur/
90         <Directory /srv/static.debian.org/mirrors/release.debian.org-pu/cur>
91                 Require all granted
92                 Options Indexes SymLinksIfOwnerMatch MultiViews
93
94                 AddEncoding gzip .gz
95                 FilterDeclare gzip CONTENT_SET
96                 FilterProvider gzip inflate "%{req:Accept-Encoding} !~ /gzip/"
97                 FilterChain gzip
98                 <Files *.debdiff.gz>
99                         ForceType text/plain
100                         AddDefaultCharset utf-8
101                 </Files>
102                 <Files *.debdiff.html.gz>
103                         ForceType text/html
104                         AddDefaultCharset utf-8
105                 </Files>
106         </Directory>
107 </Macro>
108
109 <Macro vstatic-vhost-extra-www.ports.debian.org>
110         <Directory /srv/static.debian.org/mirrors/www.ports.debian.org/cur>
111                 AllowOverride FileInfo Indexes Options=Multiviews
112                 Options Multiviews Indexes FollowSymLinks Includes
113                 Require all granted
114         </Directory>
115
116         AddOutputFilter INCLUDES .xhtml
117 </Macro>
118
119
120 <Macro vstatic-vhost-extra-lintian.debian.org>
121         AddDefaultCharset utf-8
122
123         <Directory /srv/static.debian.org/mirrors/lintian.debian.org/cur>
124                 Require all granted
125
126                 # These three lines makes apache serve
127                 # "lintian.log.gz" as a text/plain with encoding gzip
128                 # making it easier to view the log in the browser.
129                 RemoveType .gz
130                 AddEncoding x-gzip .gz
131                 AddType text/plain .log
132
133                 AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css image/svg+xml
134         </Directory>
135
136         <Directory /srv/static.debian.org/mirrors/lintian.debian.org/cur/resources>
137                 # Cache these for a year (3600 * 24 * 365.25)
138                 # Files in here will change name if their content change
139                 Header set Cache-Control "max-age=31557600, public"
140         </Directory>
141
142         RewriteEngine on
143         RewriteMap source-map txt:/srv/static.debian.org/mirrors/lintian.debian.org/cur/lookup-tables/source-packages
144
145         # Re-direct from the "old" locations to the new ones
146         RewriteRule ^/reports/T(.*)\.html$ /tags/$1.html [L,R=permanent]
147         RewriteRule ^/reports/(.*)$ /$1 [L,R=permanent]
148
149         # Map source packages to reports (this mapping is re-written once per lintian run,
150         # serve it as a 302 rather than a permanent redirect)
151         # Version-less request
152         RewriteRule ^/source/([a-z0-9-]+)/?$ /${source-map:$1} [L,R,NE]
153         # Versioned request
154         RewriteRule ^/source/([a-z0-9-]+)/([a-zA-Z0-9.+:~-]+)$ /${source-map:$1/$2} [L,R,NE]
155
156         Header always set Content-Security-Policy "default-src 'self'; media-src 'none'; object-src 'none';"
157         <FilesMatch "\.(svg)$">
158                 Header always set Content-Security-Policy "default-src 'none'; frame-ancestors 'none'; style-src 'self' 'unsafe-inline';"
159         </FilesMatch>
160 </Macro>
161
162 <%=
163
164 def vhost(lines, sn, kwargs={})
165         if scope.function_has_static_component([sn])
166                 if not kwargs[:extra]
167                                 lines << "<Macro vstatic-vhost-extra-#{sn}>"
168                                 lines << "  # mod macro does not like empty macros, so here's some content:"
169                                 lines << "  <Directory /non-existant>"
170                                 lines << "  </Directory>"
171                                 lines << "</Macro>"
172                 end
173
174                 lines << "Use prepare-static-vhost #{sn}"
175
176                 if kwargs[:ssl] and kwargs[:ssl_optional]
177                         lines << "Use static-vhost-plain-#{sn}"
178                         lines << "Use static-vhost-ssl-#{sn}"
179                 elsif kwargs[:ssl]
180                         lines << "Use common-dsa-vhost-https-redirect #{sn}"
181                         lines << "Use static-vhost-ssl-#{sn}"
182                 else
183                         lines << "Use static-vhost-plain-#{sn}"
184                 end
185
186                 onion = scope.function_onion_global_service_hostname([sn])
187                 lines << "Use static-vhost-onion-#{sn} #{onion}" if onion
188
189                 lines << ""
190         end
191 end
192
193 lines = []
194 vhost(lines, "mozilla.debian.net"            , :ssl => true, :ssl_optional => true)
195 vhost(lines, "backports.debian.org"          , :ssl => true)
196 vhost(lines, "incoming.debian.org"           , :ssl => true, :ssl_optional => true)
197 vhost(lines, "incoming.ports.debian.org"     , :ssl => true, :ssl_optional => true)
198 vhost(lines, "debdeltas.debian.net"          , :ssl => true, :ssl_optional => true)
199 vhost(lines, "news.debian.net"               , :ssl => true)
200 vhost(lines, "bootstrap.debian.net"          , :ssl => true)
201 vhost(lines, "debaday.debian.net"            , :ssl => true)
202 vhost(lines, "timeline.debian.net"           , :ssl => true)
203 vhost(lines, "network-test.debian.org"       , :extra => true)
204 vhost(lines, "blends.debian.org"             , :ssl => true)
205 vhost(lines, "wnpp-by-tags.debian.net"       , :ssl => true)
206 vhost(lines, "security-team.debian.org"      , :ssl => true)
207 vhost(lines, "d-i.debian.org"                , :ssl => true)
208 vhost(lines, "appstream.debian.org"          , :ssl => true)
209 vhost(lines, "apt.buildd.debian.org"         , :ssl => true)
210 vhost(lines, "dpl.debian.org"                , :ssl => true)
211 vhost(lines, "dsa.debian.org"                , :ssl => true)
212 vhost(lines, "rtc.debian.org"                , :ssl => true)
213 vhost(lines, "mirror-master.debian.org"      , :ssl => true)
214 vhost(lines, "onion.debian.org"              , :ssl => true)
215 vhost(lines, "manpages.debian.org"           , :ssl => true, :extra => true)
216 vhost(lines, "cdbuilder-logs.debian.org"     , :ssl => true)
217
218 vhost(lines, "bits.debian.org"               , :ssl => true, :extra => true)
219 vhost(lines, "micronews.debian.org"          , :ssl => true)
220 vhost(lines, "metadata.ftp-master.debian.org", :extra => true)
221 vhost(lines, "metadata-backend.ftp-master.debian.org", :ssl => true, :ssl_optional => true, :extra => true)
222
223 vhost(lines, "10years.debconf.org"           , :ssl => true)
224 vhost(lines, "debconf0.debconf.org"          , :ssl => true)
225 vhost(lines, "debconf1.debconf.org"          , :ssl => true)
226 vhost(lines, "debconf2.debconf.org"          , :ssl => true)
227 vhost(lines, "debconf3.debconf.org"          , :ssl => true)
228 vhost(lines, "debconf4.debconf.org"          , :ssl => true)
229 vhost(lines, "debconf5.debconf.org"          , :ssl => true)
230 vhost(lines, "debconf6.debconf.org"          , :ssl => true)
231 vhost(lines, "debconf7.debconf.org"          , :ssl => true)
232 vhost(lines, "debconf16.debconf.org"         , :ssl => true)
233 vhost(lines, "debconf17.debconf.org"         , :ssl => true)
234 vhost(lines, "debconf18.debconf.org"         , :ssl => true)
235 vhost(lines, "es.debconf.org"                , :ssl => true)
236 vhost(lines, "fr.debconf.org"                , :ssl => true)
237 vhost(lines, "miniconf10.debconf.org"        , :ssl => true)
238
239 vhost(lines, "deb.debian.org"                , :extra => true)
240 vhost(lines, "release.debian.org"            , :ssl => true, :extra => true)
241 vhost(lines, "www.ports.debian.org"          , :ssl => true, :extra => true)
242 vhost(lines, "lintian.debian.org"            , :ssl => true, :extra => true)
243
244 lines.join("\n")
245 -%>
246
247 # www.backports.org
248 ###################
249 # www.backports.org is the historical place for the backports
250 # website and archive.  It is now a CNAME to backports.debian.org:
251 # redirect http requests.
252 <VirtualHost <%= @vhost_listen %> >
253         ServerName www.backports.org
254         ServerAlias lists.backports.org
255         ServerAdmin debian-admin@debian.org
256         RedirectPermanent / https://backports.debian.org/
257 </VirtualHost>
258
259 ######################
260 <VirtualHost <%= @vhost_listen %> >
261         ServerName www.debian-ports.org
262         ServerAlias debian-ports.org
263         ServerAdmin debian-admin@debian.org
264         RedirectPermanent / https://www.ports.debian.org/
265 </VirtualHost>
266
267 <VirtualHost <%= @vhost_listen %> >
268         ServerName ports.debian.org
269         ServerAlias ports.debian.net
270         ServerAdmin debian-admin@debian.org
271         RedirectPermanent / https://www.ports.debian.org/
272 </VirtualHost>
273
274 <VirtualHost <%= @vhost_listen %> >
275         ServerName incoming.debian-ports.org
276         ServerAdmin debian-admin@debian.org
277         RedirectPermanent / http://incoming.ports.debian.org/
278 </VirtualHost>
279
280 <VirtualHost <%= @vhost_listen %> >
281         ServerName ftp.debian-ports.org
282         ServerAdmin debian-admin@debian.org
283         RedirectPermanent /archive https://www.ports.debian.org
284         RedirectPermanent /debian http://ftp.ports.debian.org/debian-ports
285         RedirectPermanent /debian-cd https://cdimage.debian.org/cdimage/ports/
286         RedirectPermanent / http://ftp.ports.debian.org/
287 </VirtualHost>
288
289 <Macro vstatic-vhost-video.debian.net>
290         ServerName video.debian.net
291         ServerAdmin debian-admin@debian.org
292         Redirect / https://meetings-archive.debian.net/pub/debian-meetings/
293 </Macro>
294
295 <VirtualHost <%= @vhost_listen %> >
296         Use vstatic-vhost-video.debian.net
297 </VirtualHost>
298
299 <VirtualHost <%= @vhost_listen_443 %> >
300         Use vstatic-vhost-video.debian.net
301         Use common-debian-service-ssl video.debian.net
302         Use common-ssl-HSTS
303 </VirtualHost>
304
305 Use common-dsa-vhost-https-redirect lists.alioth.debian.org
306 <VirtualHost <%= @vhost_listen_443 %> >
307         ServerName lists.alioth.debian.org
308         ServerAdmin debian-admin@debian.org
309         Use common-debian-service-ssl lists.alioth.debian.org
310         Use common-ssl-HSTS
311         Redirect / https://alioth-lists.debian.net/
312 </VirtualHost>
313
314 Use common-dsa-vhost-https-redirect pkg-ruby-extras.alioth.debian.org
315 <VirtualHost <%= @vhost_listen_443 %> >
316         ServerName pkg-ruby-extras.alioth.debian.org
317         ServerAdmin debian-admin@debian.org
318         Use common-debian-service-ssl pkg-ruby-extras.alioth.debian.org
319         Use common-ssl-HSTS
320         Redirect / https://gemwatch.debian.net/
321 </VirtualHost>
322
323 Use common-dsa-vhost-https-redirect video.debconf.org
324 <VirtualHost <%= @vhost_listen_443 %> >
325         ServerName video.debconf.org
326         ServerAdmin debian-admin@debian.org
327         Use common-debian-service-ssl video.debconf.org
328         Use common-ssl-HSTS
329         Redirect / https://debconf-video-team.pages.debian.net/docs/
330 </VirtualHost>
331
332 # historical sites
333 ##################
334 # now only redirects remain
335 <VirtualHost <%= @vhost_listen %> >
336         ServerName women.debian.org
337         ServerAdmin debian-admin@debian.org
338
339         RedirectPermanent / https://www.debian.org/women/
340
341         RedirectPermanent /about/ https://www.debian.org/women/about
342         RedirectPermanent /contact/ https://www.debian.org/women/contact
343         RedirectPermanent /faqs/ https://www.debian.org/women/faq
344         RedirectPermanent /home/ https://www.debian.org/women/
345         RedirectPermanent /images/dw.png https://www.debian.org/women/dw.png
346         RedirectPermanent /involvement/ https://www.debian.org/women/participate
347         RedirectPermanent /mentoring/ https://www.debian.org/women/mentoring
348         RedirectPermanent /press/ https://wiki.debian.org/DebianWomen/Press
349         RedirectPermanent /profiles/ https://www.debian.org/women/profiles/
350 </VirtualHost>
351
352 <VirtualHost <%= @vhost_listen %> >
353         ServerName volatile.debian.org
354         ServerAlias volatile-master.debian.org
355         ServerAdmin debian-admin@debian.org
356         RedirectPermanent / https://www.debian.org/volatile/
357 </VirtualHost>
358
359 <VirtualHost <%= @vhost_listen %> >
360         ServerName ftp-master.metadata.debian.org
361         ServerAdmin debian-admin@debian.org
362         RedirectPermanent / http://metadata.ftp-master.debian.org/
363 </VirtualHost>
364
365 <VirtualHost <%= @vhost_listen %> >
366         ServerName backports-master.debian.org
367         ServerAdmin debian-admin@debian.org
368         RedirectPermanent / https://backports.debian.org/
369 </VirtualHost>
370
371 <VirtualHost <%= @vhost_listen %> >
372         ServerName manpages.debian.net
373         ServerAdmin debian-admin@debian.org
374         Redirect / https://manpages.debian.org/
375 </VirtualHost>
376
377 Use common-dsa-vhost-https-redirect sources.debian.net
378 <VirtualHost <%= @vhost_listen_443 %> >
379         ServerName sources.debian.net
380         ServerAdmin debian-admin@debian.org
381         Use common-debian-service-ssl sources.debian.net
382         Use common-ssl-HSTS
383         Redirect permanent / https://sources.debian.org/
384 </VirtualHost>
385
386 # error pages
387 #############
388
389 Use common-dsa-vhost-https-redirect archive.debian.net
390 <VirtualHost <%= @vhost_listen_443 %> >
391         ServerName archive.debian.net
392         ServerAdmin debian-admin@debian.org
393         ErrorLog /var/log/apache2/archive.debian.net-error.log
394         CustomLog /var/log/apache2/archive.debian.net-access.log privacyssl
395         Use common-debian-service-ssl archive.debian.net
396         Use common-ssl-HSTS
397         Use common-disabled-service
398 </VirtualHost>
399
400
401 # vim:ft=apache: