]> git.openstreetmap.org Git - chef.git/blob - cookbooks/web/templates/default/apache.backend.erb
Trust IPs reported by Bytemark frontends
[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 <% end -%>
18
19   #
20   # Setup logging
21   #
22   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
23   CustomLog /var/log/apache2/access.log combined_with_time
24   ErrorLog /var/log/apache2/error.log
25
26   #
27   # Turn on the rewrite engine
28   #
29   RewriteEngine on
30
31   #
32   # Recover the unique ID from the request headers
33   #
34   SetEnvIf X-Request-Id ^(.*)$ UNIQUE_ID=$1
35
36   #
37   # Configure rails
38   #
39   DocumentRoot <%= node[:web][:base_directory] %>/rails/public
40   RailsEnv production
41   PassengerMinInstances 3
42   PassengerMaxRequests 500
43 <% if port == 443 -%>
44   PassengerPreStart https://www.openstreetmap.org/
45 <% else -%>
46   PassengerPreStart http://www.openstreetmap.org/
47 <% end -%>
48   SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
49
50   #
51   # Get the real remote IP for requests via a trusted proxy
52   #
53   RemoteIPHeader X-Forwarded-For
54   RemoteIPTrustedProxy 146.179.159.160/27
55   RemoteIPTrustedProxy 10.0.32.0/24
56
57   #
58   # Pass supported calls to cgimap
59   #
60   RewriteRule ^/api/0\.6/map$ fcgi://127.0.0.1:8000$0 [P]
61   RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
62   RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+$ fcgi://127.0.0.1:8000$0 [P]
63   RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full$ fcgi://127.0.0.1:8000$0 [P]
64   RewriteRule ^/api/0\.6/(nodes|ways|relations)$ fcgi://127.0.0.1:8000$0 [P]
65 </VirtualHost>
66 <% end -%>
67
68 <Directory <%= node[:web][:base_directory] %>/rails/public>
69   Require all granted
70 </Directory>