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