]> git.openstreetmap.org Git - chef.git/blob - cookbooks/web/templates/default/apache.frontend.erb
Remove general redirect from https to http
[chef.git] / cookbooks / web / templates / default / apache.frontend.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 <% [80, 443].each do |port| -%>
4 <VirtualHost *:<%= port %>>
5   #
6   # Basic server configuration
7   #
8   ServerName <%= node[:fqdn] %>
9   ServerAlias api.openstreetmap.org www.openstreetmap.org
10   ServerAdmin webmaster@openstreetmap.org
11 <% if port == 443 -%>
12
13   #
14   # Enable SSL
15   #
16   SSLEngine on
17 <% end -%>
18
19   #
20   # Setup logging
21   #
22   LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Ts" combined_with_time
23   CustomLog /var/log/apache2/access.log combined_with_time
24   ErrorLog /var/log/apache2/error.log
25
26   #
27   # Turn on various features
28   #
29   ExpiresActive On
30   RewriteEngine on
31
32   #
33   # Block troublesome GPX data scrapping
34   #
35   RewriteCond %{REQUEST_METHOD} HEAD
36   RewriteRule ^/trace/\d+/data - [F,L]
37
38   #
39   # Block tilesAtHome
40   #
41   RewriteCond %{HTTP_USER_AGENT} tilesAtHome
42   RewriteRule . - [F,L]
43
44   #
45   # Block requests for the old 404 map tile
46   #
47   RewriteRule ^/openlayers/img/404.png$ - [G,L]
48
49   #
50   # Block attempts to access old API versions
51   #
52   RewriteRule ^/api/0.[12345]/ - [G,L]
53
54   #
55   # Block JOSM revisions  1722-1727 as they have a serious bug that causes
56   # lat/lon to be swapped (http://josm.openstreetmap.de/ticket/2804)
57   #
58   RewriteCond %{HTTP_USER_AGENT} "^JOSM/[0-9]+\.[0-9]+ \(172[234567]\)"
59   RewriteRule . - [F,L]
60
61   #
62   # Block a changeset that seems to lock things up
63   #
64   RewriteRule ^/api/0.6/changeset/6823497/download$ - [F,L]
65
66   #
67   # Force special MIME type for crossdomain.xml files
68   #
69   <Files crossdomain.xml>
70     ForceType text/x-cross-domain-policy
71   </Files>
72
73   #
74   # Set expiry for assets
75   #
76   <Location /assets/>
77     Header unset Last-Modified
78     Header unset ETag
79     FileETag None
80
81     ExpiresDefault "access plus 1 year"
82   </Location>
83
84   #
85   # Set expiry for attachments
86   #
87   <Location /attachments/>
88     Header unset Last-Modified
89     Header unset ETag
90     FileETag None
91
92     ExpiresDefault "access plus 1 year"
93   </Location>
94
95   #
96   # Set expiry for other static content
97   #
98   <Location /export/embed.html>
99     ExpiresDefault "access plus 7 days"
100   </Location>
101   <Location /images/>
102     ExpiresDefault "access plus 10 years"
103   </Location>
104   <Location /javascripts/>
105     ExpiresDefault "access plus 10 years"
106   </Location>
107   <Location /openlayers/>
108     ExpiresDefault "access plus 7 days"
109   </Location>
110   <Location /stylesheets/>
111     ExpiresDefault "access plus 10 years"
112   </Location>
113
114   #
115   # Set expiry for Potlatch 1
116   #
117   <Location /potlatch/>
118     ExpiresDefault "access plus 7 days"
119   </Location>
120
121   #
122   # Set expiry for Potlatch 2
123   #
124   <Location /potlatch2/>
125     ExpiresByType application/x-shockwave-flash "access plus 1 day"
126     ExpiresByType application/xml "access plus 1 day"
127     ExpiresByType text/css "access plus 1 day"
128     ExpiresByType image/png "access plus 7 days"
129   </Location>
130
131   #
132   # Configure rails
133   #
134   DocumentRoot <%= node[:web][:base_directory] %>/rails/public
135   RailsEnv production
136   PassengerMinInstances 10
137   PassengerMaxRequests 5000
138   PassengerPreStart http://www.openstreetmap.org/
139   Alias /favicon.ico <%= node[:web][:base_directory] %>/rails/app/assets/images/favicon.ico
140   Alias /openlayers <%= node[:web][:base_directory] %>/rails/vendor/assets/openlayers
141   Alias /stats /store/rails/stats
142   Alias /user/image /store/rails/user/image
143   Alias /attachments /store/rails/attachments
144
145   #
146   # Preserve the host name when forwarding to the proxy
147   #
148   ProxyPreserveHost on
149
150   #
151   # Set a long timeout - changeset uploads can take a long time
152   #
153   ProxyTimeout 3600
154
155   #
156   # Allow all proxy requests
157   #
158   <Proxy *>
159     Allow from all
160   </Proxy>
161
162   #
163   # Pass some other API calls to the backends via a load balancer
164   #
165   ProxyPass /api/0.6/map balancer://backend/api/0.6/map
166   ProxyPass /api/0.6/tracepoints balancer://backend/api/0.6/tracepoints
167   ProxyPass /api/0.6/amf/read balancer://backend/api/0.6/amf/read
168   ProxyPass /api/0.6/swf/trackpoints balancer://backend/api/0.6/swf/trackpoints
169   ProxyPassMatch ^(/api/0\.6/changeset/[0-9]+/(upload|download))$ balancer://backend$1
170   ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+)$ balancer://backend$1
171   ProxyPassMatch ^(/api/0\.6/(node|way|relation)/[0-9]+/(full|history|search|ways))$ balancer://backend$1
172   ProxyPass /api/0.6/nodes balancer://backend/api/0.6/nodes
173   ProxyPass /api/0.6/ways balancer://backend/api/0.6/ways
174   ProxyPass /api/0.6/relations balancer://backend/api/0.6/relations
175   ProxyPassMatch ^(/trace/[0-9]+/data(|/|.xml))$ balancer://backend$1
176
177   #
178   # Redirect trac and wiki requests to the right places
179   #
180   RedirectPermanent /trac/ http://trac.openstreetmap.org/
181   RedirectPermanent /wiki/ http://wiki.openstreetmap.org/
182
183   #
184   # Redirect requests for various images to the right place
185   #
186   RedirectPermanent /images/osm_logo.png http://www.openstreetmap.org/assets/osm_logo.png
187   RedirectPermanent /images/cc_button.png http://www.openstreetmap.org/assets/cc_button.png
188
189   #
190   # Define a load balancer for the backends
191   #
192   <Proxy balancer://backend>
193     ProxySet lbmethod=bybusyness
194     BalancerMember http://rails1
195     BalancerMember http://rails2
196     BalancerMember http://rails3
197   </Proxy>
198 <% if port == 80 -%>
199
200   #
201   # Redirect requests which should be secure to https
202   #
203   RewriteCond %{REQUEST_URI} ^/login(\.html)?$ [OR]
204   RewriteCond %{REQUEST_URI} ^/user/(new|create-account\.html)$ [OR]
205   RewriteCond %{REQUEST_URI} ^/user/terms$ [OR]
206   RewriteCond %{REQUEST_URI} ^/user/save$ [OR]
207   RewriteCond %{REQUEST_URI} ^/user/([^/]+)/account$ [OR]
208   RewriteCond %{REQUEST_URI} ^/user/reset-password$
209   RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
210
211   #
212   # Redirect api requests made to www.osm.org to api.osm.org
213   #
214 #  RewriteCond %{HTTP_HOST} =www.openstreetmap.org
215 #  RewriteRule ^/api/(.*)$ http://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
216
217   #
218   # Redirect non-api requests made to api.osm.org to www.osm.org
219   #
220   RewriteCond %{HTTP_HOST} =api.openstreetmap.org
221   RewriteCond %{REQUEST_URI} !^/api/
222   RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
223 <% elsif port == 443 -%>
224
225   #
226   # Redirect requests which don't work over https to http
227   #
228   RewriteCond %{REQUEST_URI} !^/edit$
229   RewriteRule ^(.*)$ http://www.openstreetmap.org$1 [L,NE,R=permanent]
230
231   #
232   # Redirect api requests made to www.osm.org to api.osm.org
233   #
234 #  RewriteCond %{HTTP_HOST} =www.openstreetmap.org
235 #  RewriteRule ^/api/(.*)$ https://api.openstreetmap.org/api/$1 [L,NE,R=permanent]
236
237   #
238   # Redirect non-api requests made to api.osm.org to www.osm.org
239   #
240   RewriteCond %{HTTP_HOST} =api.openstreetmap.org
241   RewriteCond %{REQUEST_URI} !^/api/
242   RewriteRule ^(.*)$ https://www.openstreetmap.org$1 [L,NE,R=permanent]
243 <% end -%>
244 </VirtualHost>
245
246 <% end -%>
247 <VirtualHost *:80>
248   ServerName openstreetmap.org
249   ServerAlias maps.openstreetmap.org mapz.openstreetmap.org
250   ServerAlias openstreetmap.com www.openstreetmap.com
251   ServerAlias maps.openstreetmap.com mapz.openstreetmap.com
252   ServerAlias openstreetmap.net www.openstreetmap.net
253   ServerAlias maps.openstreetmap.net mapz.openstreetmap.net
254   ServerAlias openstreetmap.ca www.openstreetmap.ca
255   ServerAlias maps.openstreetmap.ca mapz.openstreetmap.ca
256   ServerAlias openstreetmap.eu www.openstreetmap.eu
257   ServerAlias maps.openstreetmap.eu mapz.openstreetmap.eu
258   ServerAlias openstreetmap.pro www.openstreetmap.pro
259   ServerAlias maps.openstreetmap.pro mapz.openstreetmap.pro
260   ServerAlias openstreetmaps.org www.openstreetmaps.org
261   ServerAlias maps.openstreetmaps.org mapz.openstreetmaps.org
262   ServerAlias osm.org www.osm.org
263   ServerAlias maps.osm.org mapz.osm.org
264   ServerAlias openmaps.org www.openmaps.org
265   ServerAlias maps.openmaps.org mapz.openmaps.org
266   ServerAlias openstreetmap.io www.openstreetmap.io
267   ServerAlias maps.openstreetmap.io mapz.openstreetmap.io
268   ServerAlias osm.io www.osm.io
269   ServerAlias maps.osm.io mapz.osm.io
270   ServerAlias openworldmap.org www.openworldmap.org
271   ServerAlias maps.openworldmap.org mapz.openworldmap.org
272   ServerAlias freeosm.org www.freeosm.org
273   ServerAlias maps.freeosm.org mapz.freeosm.org
274   ServerAlias open-maps.org www.open-maps.org
275   ServerAlias maps.open-maps.org mapz.open-maps.org
276   ServerAlias open-maps.com www.open-maps.com
277   ServerAlias maps.open-maps.com mapz.open-maps.com
278
279   #Third Party Sites
280   ServerAlias openstreetmap.pm www.openstreetmap.pm
281
282   RedirectPermanent / http://www.openstreetmap.org/
283 </VirtualHost>
284
285 <VirtualHost *:80>
286   ServerName openstreetmap.org.uk
287   ServerAlias www.openstreetmap.org.uk
288   ServerAlias openstreetmap.co.uk
289   ServerAlias www.openstreetmap.co.uk
290
291   RedirectPermanent /events.ics http://calendar.openstreetmap.org.uk/events.ics
292   RedirectPermanent / http://www.openstreetmap.org/
293 </VirtualHost>