]> git.openstreetmap.org Git - chef.git/blob - cookbooks/nominatim/templates/default/apache.erb
1afe817e58bcaf8744b61e6fa814fa405c9225c4
[chef.git] / cookbooks / nominatim / templates / default / apache.erb
1 # DO NOT EDIT - This file is being maintained by Chef
2
3 <% [80, 443].each do |port| -%>
4 <VirtualHost *:<%= port %>>
5     ServerName <%= node[:fqdn] %>
6     ServerAlias nominatim.openstreetmap.org
7     ServerAlias nominatim.osm.org
8     ServerAlias nominatim.openstreetmap.org
9     ServerAlias nominatim.openstreetmap.net
10     ServerAlias nominatim.openstreetmaps.org
11     ServerAlias nominatim.openmaps.org
12     ServerAdmin webmaster@openstreetmap.org
13
14 <% if port == 443 -%>
15     #
16     # Enable SSL
17     #
18     SSLEngine on
19     SSLProxyEngine on
20 <% end -%>
21
22     # Remove Proxy request header to mitigate https://httpoxy.org/
23     RequestHeader unset Proxy early
24
25     CustomLog /var/log/apache2/nominatim.openstreetmap.org-access.log combined
26     ErrorLog /var/log/apache2/nominatim.openstreetmap.org-error.log
27
28     DocumentRoot <%= @directory %>/website
29     <Directory "<%= @directory %>/website/">
30         DirectoryIndex search.php
31         Options FollowSymLinks
32         Require all granted
33     </Directory>
34
35     ProxyPassMatch ^/([^/]*\.php(/.*)?)$ fcgi://127.0.0.1:<%= @pools[:www][:port ]%><%= @directory %>/website/$1
36
37     <% @pools.each do |name,details| -%>
38     Alias /pool-<%= name %>/ "<%= @directory %>/website/"
39     <% node[:nominatim][:redirects].each do |url,host| -%>
40     ProxyPassMatch ^/pool-<%= name %>/(<%= url %>\.php(/.*)?) http<% if port == 443 -%>s<% end -%>://<%= host %>/pool-<%= name %>/$1
41     <% end -%>
42     ProxyPassMatch ^/pool-<%= name %>/(.*\.php(/.*)?) fcgi://127.0.0.1:<%= details[:port ]%><%= @directory %>/website/$1
43     <% end -%>
44
45     Redirect 429 /pool-block/
46     ErrorDocument 429 /509.html
47     <Location /pool-block>
48         ErrorDocument 429 /509.html
49     </Location>
50     Redirect 403 /pool-ban/
51     <Location /pool-ban>
52         ErrorDocument 403 /403.html
53     </Location>
54     ErrorDocument 403 /403.html
55
56     RewriteEngine On
57
58     # manual blocks
59     Include <%= @directory %>/settings/apache_blocks.conf
60
61     # regular requests and autoblocks
62     RewriteMap bulklist txt:<%= @directory %>/settings/ip_blocks.map
63     RewriteRule ^/(search|reverse|lookup)(\.php)?(/.*)? /pool-${bulklist:%{REMOTE_ADDR}|www}/$1.php$3 [PT]
64     RewriteRule ^/details(\.php)?(/.*)? /pool-${bulklist:%{REMOTE_ADDR}|details}/details.php$2 [PT]
65
66 </VirtualHost>
67
68 <% end -%>