# DO NOT EDIT - This file is being maintained by Chef
+<% [80, 443].each do |port| -%>
-<VirtualHost *:80>
+<VirtualHost *:<%= port %>>
#
# Basic server configuration
#
ServerName <%= node[:fqdn] %>
ServerAlias api.openstreetmap.org www.openstreetmap.org
ServerAdmin webmaster@openstreetmap.org
+<% if port == 443 -%>
+
+ #
+ # Enable SSL
+ #
+ SSLEngine on
+<% end -%>
#
# Setup logging
#
- LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Ts" combined_with_time
+ LogFormat "%a %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" %Ts" combined_with_time
CustomLog /var/log/apache2/access.log combined_with_time
ErrorLog /var/log/apache2/error.log
+ #
+ # Turn on the rewrite engine
+ #
+ RewriteEngine on
+
#
# Configure rails
#
RailsEnv production
PassengerMinInstances 3
PassengerMaxRequests 500
+<% if port == 443 -%>
+ PassengerPreStart https://www.openstreetmap.org/
+<% else -%>
PassengerPreStart http://www.openstreetmap.org/
+<% end -%>
+ SetEnv SECRET_KEY_BASE <%= @secret_key_base %>
#
# Get the real remote IP for requests via a trusted proxy
RemoteIPTrustedProxy 146.179.159.160/27
#
- # Pass map calls to cgimap
+ # Pass supported calls to cgimap
#
- <Location /api/0.6/map>
- SetHandler fcgi:127.0.0.1:8000
- </Location>
+ RewriteRule ^/api/0\.6/map$ fcgi://127.0.0.1:8000$0 [P]
+ RewriteCond %{REQUEST_METHOD} ^(HEAD|GET)$
+ RewriteRule ^/api/0\.6/(node|way|relation)/[0-9]+$ fcgi://127.0.0.1:8000$0 [P]
+ RewriteRule ^/api/0\.6/(way|relation)/[0-9]+/full$ fcgi://127.0.0.1:8000$0 [P]
+ RewriteRule ^/api/0\.6/(nodes|ways|relations)$ fcgi://127.0.0.1:8000$0 [P]
</VirtualHost>
+<% end -%>
+
+<Directory <%= node[:web][:base_directory] %>/rails/public>
+ Require all granted
+</Directory>