]> git.openstreetmap.org Git - chef.git/blob - cookbooks/web/templates/default/apache.backend.erb
Send changeset download requests to cgimap
[chef.git] / cookbooks / web / templates / default / apache.backend.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2 <% [80, 443].each do |port| -%>
3
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   SSLCertificateFile /etc/ssl/certs/www.openstreetmap.org.pem
18   SSLCertificateKeyFile /etc/ssl/private/www.openstreetmap.org.key
19 <% end -%>
20
21   #
22   # Setup logging
23   #
24   LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Dus %{UNIQUE_ID}e %{SSL_PROTOCOL}x %{SSL_CIPHER}x" combined_with_time
25   CustomLog /var/log/apache2/access.log combined_with_time
26   ErrorLog /var/log/apache2/error.log
27
28   #
29   # Turn on the rewrite engine
30   #
31   RewriteEngine on
32
33   #
34   # Recover the unique ID from the request headers
35   #
36   SetEnvIf X-Request-Id ^(.*)$ UNIQUE_ID=$1
37
38   #
39   # Configure rails
40   #
41   DocumentRoot <%= node[:web][:base_directory] %>/rails/public
42   RailsEnv production
43   PassengerMinInstances 3
44   PassengerMaxRequests 500
45 <% if port == 443 -%>
46   PassengerPreStart https://www.openstreetmap.org/
47 <% else -%>
48   PassengerPreStart http://www.openstreetmap.org/
49 <% end -%>
50   SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
51
52   #
53   # Get the real remote IP for requests via a trusted proxy
54   #
55   RemoteIPHeader X-Forwarded-For
56   RemoteIPTrustedProxy 146.179.159.160/27
57   RemoteIPTrustedProxy 10.0.32.0/24
58
59   #
60   # Pass authentication related headers to cgimap
61   #
62   <Location />
63     CGIPassAuth On
64   </Location>
65
66   #
67   # Pass supported calls to cgimap
68   #
69   RewriteRule ^/api/0\.6/map$ fcgi://127.0.0.1:8000$0 [P]
70   RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
71   RewriteRule ^/api/0\.6/changeset/[0-9]+/download$ fcgi://127.0.0.1:8000$0 [P]
72   RewriteRule ^/api/0\.6/(node|way|relation|changeset)/[0-9]+$ fcgi://127.0.0.1:8000$0 [P]
73   RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full$ fcgi://127.0.0.1:8000$0 [P]
74   RewriteRule ^/api/0\.6/(nodes|ways|relations)$ fcgi://127.0.0.1:8000$0 [P]
75 </VirtualHost>
76 <% end -%>
77
78 <Directory <%= node[:web][:base_directory] %>/rails/public>
79   Require all granted
80 </Directory>