]> git.openstreetmap.org Git - chef.git/blob - cookbooks/nominatim/templates/default/apache.erb
fix details URL rewrite
[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     CustomLog /var/log/apache2/nominatim.openstreetmap.org-access.log combined
23     ErrorLog /var/log/apache2/nominatim.openstreetmap.org-error.log
24
25     DocumentRoot <%= @directory %>/website
26     <Directory "<%= @directory %>/website/">
27         DirectoryIndex search.php
28         Options FollowSymLinks
29         Require all granted
30     </Directory>
31
32     ProxyPassMatch ^/([^/]*\.php(/.*)?)$ fcgi://127.0.0.1:<%= @pools[:www][:port ]%><%= @directory %>/website/$1
33
34     <% @pools.each do |name,details| -%>
35     Alias /pool-<%= name %>/ "<%= @directory %>/website/"
36     <% node[:nominatim][:redirects].each do |url,host| -%>
37     ProxyPassMatch ^/pool-<%= name %>/(<%= url %>\.php(/.*)?) http<% if port == 443 -%>s<% end -%>://<%= host %>/pool-<%= name %>/$1
38     <% end -%>
39     ProxyPassMatch ^/pool-<%= name %>/(.*\.php(/.*)?) fcgi://127.0.0.1:<%= details[:port ]%><%= @directory %>/website/$1
40     <% end -%>
41
42     Redirect 429 /pool-block/
43     ErrorDocument 429 /509.html
44     <Location /pool-block>
45         ErrorDocument 429 /509.html
46     </Location>
47     Redirect 403 /pool-ban/
48     <Location /pool-ban>
49         ErrorDocument 403 /403.html
50     </Location>
51     ErrorDocument 403 /403.html
52
53     RewriteEngine On
54
55     # manual blocks
56     Include <%= @directory %>/settings/apache_blocks.conf
57
58     # regular requests and autoblocks
59     RewriteMap bulklist txt:<%= @directory %>/settings/ip_blocks.map
60     RewriteRule ^/(search|reverse|lookup)(\.php)?(/.*)? /pool-${bulklist:%{REMOTE_ADDR}|www}/$1.php$3 [PT]
61     RewriteRule ^/details(\.php)?(/.*)? /pool-${bulklist:%{REMOTE_ADDR}|details}/details.php$2 [PT]
62
63 </VirtualHost>
64
65 <% end -%>