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