]> git.openstreetmap.org Git - chef.git/blob - cookbooks/planet/templates/default/apache.erb
02332da7a5f382f4124e902e968fd07131e505bd
[chef.git] / cookbooks / planet / templates / default / apache.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 <VirtualHost *:443>
4         ServerName planet.openstreetmap.org
5         ServerAlias planet.osm.org
6         ServerAdmin webmaster@openstreetmap.org
7
8         CustomLog /var/log/apache2/planet.openstreetmap.org-access.log combined
9         ErrorLog /var/log/apache2/planet.openstreetmap.org-error.log
10
11         SSLEngine on
12         SSLCertificateFile /etc/ssl/certs/planet.openstreetmap.org.pem
13         SSLCertificateKeyFile /etc/ssl/private/planet.openstreetmap.org.key
14
15         DocumentRoot /store/planet
16
17         <Directory /store/planet>
18                 Options Indexes FollowSymLinks MultiViews ExecCGI
19                 AllowOverride All
20                 IndexIgnore .ht* . robots.txt HEADER.html HEADER.cgi logo.png style.css
21                 IndexOptions FancyIndexing FoldersFirst NameWidth=* TrackModified SuppressHTMLPreamble
22                 HeaderName HEADER.cgi
23                 IndexOrderDefault Descending Date
24                 AddType text/html .cgi
25                 AddHandler cgi-script .cgi
26                 Require all granted
27         </Directory>
28
29         Redirect /pbf-experimental/     /pbf/
30
31         <IfModule mod_headers.c>
32                 Header set Access-Control-Allow-Origin "*"
33         </IfModule>
34
35         RewriteEngine on
36         RewriteMap latestplanet prg:/usr/local/bin/apache-latest-planet-filename
37         RewriteMap ip2region prg:/usr/local/bin/apache-s3-ip2region
38
39         # Direct, no redirect for the following
40         RewriteCond %{REMOTE_ADDR} ^(127\.|10\.|192\.168\.) 
41         RewriteCond %{QUERY_STRING} nomirror
42         RewriteRule     .* - [L]
43
44         # Set ENV:REGION to AWS region closest to the user 
45         RewriteRule .* - [E=REGION:${ip2region:%{REMOTE_ADDR}|eu-central-1}]
46
47         # Use RewriteMap latestplanet to redirect -latest symlink to resolved file eg: planet-latest.osm.bz2 -> 2023/planet-230918.osm.bz2
48         RewriteRule ^(/planet/planet\-latest\.osm\.bz2(\.torrent)?)$                ${latestplanet:$1} [R,L]
49         RewriteRule ^(/planet/full\-history/history\-latest\.osm\.bz2(\.torrent)?)$ ${latestplanet:$1} [R,L]
50         RewriteRule ^(/planet/changesets\-latest\.osm\.bz2(\.torrent)?)$            ${latestplanet:$1} [R,L]
51         RewriteRule ^(/planet/discussions\-latest\.osm\.bz2(\.torrent)?)$           ${latestplanet:$1} [R,L]
52
53         RewriteRule ^(/pbf/planet\-latest\.osm\.pbf(\.torrent)?)$                   ${latestplanet:$1} [R,L]
54         RewriteRule ^(/pbf/full\-history/history\-latest\.osm\.pbf(\.torrent)?)$    ${latestplanet:$1} [R,L]
55
56         RewriteRule ^(/cc\-by\-sa/pbf/planet\-latest\.osm\.pbf)$        ${latestplanet:$1} [R,L]
57         RewriteRule ^(/cc\-by\-sa/planet\-latest\.osm\.bz2)$            ${latestplanet:$1} [R,L]
58         RewriteRule ^(/cc\-by\-sa/changesets\-latest\.osm\.bz2)$        ${latestplanet:$1} [R,L]
59         RewriteRule ^(/cc\-by\-sa/relations\-latest\.osm\.bz2)$         ${latestplanet:$1} [R,L]
60
61         RewriteRule ^(/notes/planet\-notes\-latest\.osn\.bz2)$         ${latestplanet:$1} [R,L]
62
63         # Block an abusive fake user agent
64         RewriteCond %{HTTP_USER_AGENT} "=Mozilla/5.0 (Linux; Android) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36"
65         RewriteRule /.*$ - [F,L]
66
67         <% start_year = 2008 %>
68         <% current_year = Time.now.year %>
69         <% (start_year..current_year).each do |year| %>
70           <% year_two = sprintf('%02d', year % 100) %>
71           <% if year == current_year %>
72         RewriteRule ^/pbf/(planet\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.pbf(\.torrent|\.md5)?)$ https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/planet/pbf/<%= year %>/$1 [R,L]
73         RewriteRule ^/pbf/full\-history/(history\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.pbf(\.torrent|\.md5)?)$ https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/planet-full-history/pbf/<%= year %>/$1 [R,L]
74         RewriteRule ^/planet/<%= year %>/(planet\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.bz2(\.torrent|\.md5)?)$ https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/planet/osm/<%= year %>/$1 [R,L]
75         RewriteRule ^/planet/<%= year %>/(changesets\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.bz2(\.torrent|\.md5)?)$ https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/changesets/osm/<%= year %>/$1 [R,L]
76         RewriteRule ^/planet/<%= year %>/(discussions\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.bz2(\.torrent|\.md5)?)$ https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/discussions/osm/<%= year %>/$1 [R,L]
77         RewriteRule ^/planet/full\-history/<%= year %>/(history\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.bz2(\.torrent|\.md5)?)$ https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/planet-full-history/osm/<%= year %>/$1 [R,L]
78         RewriteRule ^/tile_logs/(hosts\-<%= year %>\-[01][0-9]\-[0-3][0-9]\.csv) https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/tile_logs/standard_layer/hosts/<%= year %>/$1 [R,L]
79         RewriteRule ^/tile_logs/(countries\-<%= year %>\-[01][0-9]\-[0-3][0-9]\.csv) https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/tile_logs/standard_layer/countries/<%= year %>/$1 [R,L]
80         RewriteRule ^/tile_logs/(apps\-<%= year %>\-[01][0-9]\-[0-3][0-9]\.csv) https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/tile_logs/standard_layer/apps/<%= year %>/$1 [R,L]
81         RewriteRule ^/tile_logs/(tiles\-<%= year %>\-[01][0-9]\-[0-3][0-9]\.txt\.xz) https://osm-planet-eu-central-1.s3.dualstack.eu-central-1.amazonaws.com/tile_logs/standard_layer/tiles/<%= year %>/$1 [R,L]
82           <% else %>
83         RewriteRule ^/pbf/(planet\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.pbf(\.torrent|\.md5)?)$ https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/planet/pbf/<%= year %>/$1 [R,L]
84         RewriteRule ^/pbf/full\-history/(history\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.pbf(\.torrent|\.md5)?)$ https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/planet-full-history/pbf/<%= year %>/$1 [R,L]
85         RewriteRule ^/planet/<%= year %>/(planet\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.bz2(\.torrent|\.md5)?)$ https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/planet/osm/<%= year %>/$1 [R,L]
86         RewriteRule ^/planet/<%= year %>/(changesets\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.bz2(\.torrent|\.md5)?)$ https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/changesets/osm/<%= year %>/$1 [R,L]
87         RewriteRule ^/planet/<%= year %>/(discussions\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.bz2(\.torrent|\.md5)?)$ https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/discussions/osm/<%= year %>/$1 [R,L]
88         RewriteRule ^/planet/full\-history/<%= year %>/(history\-<%= year_two %>[0-1][0-9][0-3][0-9]\.osm\.bz2(\.torrent|\.md5)?)$ https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/planet-full-history/osm/<%= year %>/$1 [R,L]
89         RewriteRule ^/tile_logs/(hosts\-<%= year %>\-[01][0-9]\-[0-3][0-9]\.csv) https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/tile_logs/standard_layer/hosts/<%= year %>/$1 [R,L]
90         RewriteRule ^/tile_logs/(countries\-<%= year %>\-[01][0-9]\-[0-3][0-9]\.csv) https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/tile_logs/standard_layer/countries/<%= year %>/$1 [R,L]
91         RewriteRule ^/tile_logs/(apps\-<%= year %>\-[01][0-9]\-[0-3][0-9]\.csv) https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/tile_logs/standard_layer/apps/<%= year %>/$1 [R,L]
92         RewriteRule ^/tile_logs/(tiles\-<%= year %>\-[01][0-9]\-[0-3][0-9]\.txt\.xz) https://osm-planet-%{ENV:REGION}.s3.dualstack.%{ENV:REGION}.amazonaws.com/tile_logs/standard_layer/tiles/<%= year %>/$1 [R,L]
93           <% end %>
94         <% end %>
95 </VirtualHost>
96
97 <VirtualHost *:80>
98         ServerName planet.openstreetmap.org
99         ServerAlias planet.osm.org
100         ServerAdmin webmaster@openstreetmap.org
101
102         CustomLog /var/log/apache2/planet.openstreetmap.org-access.log combined
103         ErrorLog /var/log/apache2/planet.openstreetmap.org-error.log
104
105         RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
106         RedirectPermanent / https://planet.openstreetmap.org/
107 </VirtualHost>