]> git.openstreetmap.org Git - chef.git/blob - cookbooks/nominatim/templates/default/apache.erb
Switch nominatim.osm.org to letsencrypt
[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.com
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     # Enable SSL
16     SSLEngine on
17     SSLProxyEngine on
18     SSLCertificateFile /etc/ssl/certs/nominatim.openstreetmap.org.pem
19     SSLCertificateKeyFile /etc/ssl/private/nominatim.openstreetmap.org.key
20 <% else -%>
21     # Redirect ACME challenges for certificate issuance
22     RedirectPermanent /.well-known/acme-challenge/ http://acme.openstreetmap.org/.well-known/acme-challenge/
23 <% end -%>
24
25     # Remove Proxy request header to mitigate https://httpoxy.org/
26     RequestHeader unset Proxy early
27
28     CustomLog /var/log/apache2/nominatim.openstreetmap.org-access.log combined
29     ErrorLog /var/log/apache2/nominatim.openstreetmap.org-error.log
30
31     DocumentRoot <%= @directory %>/website
32     <Directory "<%= @directory %>/website/">
33         DirectoryIndex search.php
34         Options FollowSymLinks
35         Require all granted
36     </Directory>
37
38     ProxyPassMatch ^/([^/]*\.php(/.*)?)$ fcgi://127.0.0.1:<%= @pools[:www][:port ]%><%= @directory %>/website/$1
39
40     <% @pools.each do |name,details| -%>
41     Alias /pool-<%= name %>/ "<%= @directory %>/website/"
42     <% node[:nominatim][:redirects].each do |url,host| -%>
43     ProxyPassMatch ^/pool-<%= name %>/(<%= url %>\.php(/.*)?) http<% if port == 443 -%>s<% end -%>://<%= host %>/pool-<%= name %>/$1
44     <% end -%>
45     ProxyPassMatch ^/pool-<%= name %>/(.*\.php(/.*)?) fcgi://127.0.0.1:<%= details[:port ]%><%= @directory %>/website/$1
46     <% end -%>
47
48     Redirect 429 /pool-block/
49     ErrorDocument 429 /509.html
50     <Location /pool-block>
51         ErrorDocument 429 /509.html
52     </Location>
53     Redirect 403 /pool-ban/
54     <Location /pool-ban>
55         ErrorDocument 403 /403.html
56     </Location>
57     ErrorDocument 403 /403.html
58
59     RewriteEngine On
60
61     # manual blocks
62     Include <%= @directory %>/settings/apache_blocks.conf
63
64     # regular requests and autoblocks
65     RewriteMap bulklist txt:<%= @directory %>/settings/ip_blocks.map
66     RewriteRule ^/(search|reverse|lookup)(\.php)?(/.*)? /pool-${bulklist:%{REMOTE_ADDR}|www}/$1.php$3 [PT]
67     RewriteRule ^/details(\.php)?(/.*)? /pool-${bulklist:%{REMOTE_ADDR}|details}/details.php$2 [PT]
68
69 </VirtualHost>
70
71 <% end -%>