1 upstream nominatim_service {
2 server unix:/run/php/nominatim.openstreetmap.org.sock;
5 map $uri $nominatim_script_name {
11 map $uri $nominatim_path_info {
17 ~(^|&)format=html(&|$) html;
21 map $uri/$format $forward_to_ui {
25 ~/reverse.*/default 0;
30 map $query_string $email_id {
31 ~(^|&)email=([^&]+) $2;
34 map $email_id $missing_email {
39 map $http_user_agent $missing_ua {
44 map $http_referer $missing_referer {
52 <% @frontends.each do |frontend| -%>
53 <% frontend.ipaddresses(:role => :external).sort.each do |address| -%>
65 map $missing_email$missing_referer$http_user_agent $blocked_user_agent {
67 "11" 2; # block any requests without identifier
68 include <%= @confdir %>/nginx_blocked_user_agent.conf;
71 map $missing_email$missing_ua$http_referer $blocked_referrer {
73 include <%= @confdir %>/nginx_blocked_referrer.conf;
76 map $missing_referer$missing_ua$email_id $blocked_email {
78 include <%= @confdir %>/nginx_blocked_email.conf;
81 map $whitelisted $limit_www {
83 0 $binary_remote_addr;
86 map $blocked_user_agent $limit_tarpit {
88 1 $binary_remote_addr;
89 2 $binary_remote_addr;
92 map $missing_email$missing_referer$http_user_agent $generic_mozilla {
98 map $whitelisted$generic_mozilla$uri $limit_reverse {
100 ~01/reverse.* $binary_remote_addr;
101 ~02/reverse.* $binary_remote_addr;
104 limit_req_zone $limit_www zone=www:50m rate=2r/s;
105 limit_req_zone $limit_tarpit zone=tarpit:10m rate=1r/s;
106 limit_req_zone $binary_remote_addr zone=blocked:10m rate=20r/m;
107 limit_req_zone $limit_reverse zone=reverse:10m rate=10r/m;
110 listen 80 default_server;
111 listen [::]:80 default_server;
113 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
114 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
116 location /nginx_status {
124 rewrite ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 permanent;
127 return 301 https://$host$request_uri;
133 listen 443 ssl http2 default_server;
135 listen [::]:443 ssl http2 default_server;
136 server_name localhost;
138 ssl_certificate /etc/ssl/certs/<%= node[:fqdn] %>.pem;
139 ssl_certificate_key /etc/ssl/private/<%= node[:fqdn] %>.key;
141 root <%= @directory %>/website;
144 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
145 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
147 location /nginx_status {
155 error_page 403 /403.html;
157 limit_req zone=blocked burst=5;
160 error_page 429 /509.html;
162 limit_req zone=blocked burst=5;
166 try_files $uri $uri/ @php;
170 alias <%= @ui_directory %>/dist/;
175 add_header Access-Control-Allow-Origin "*" always;
179 if ($blocked_user_agent ~ ^2$)
181 if ($blocked_referrer)
185 include <%= @confdir %>/nginx_blocked_generic.conf;
187 limit_req zone=www burst=10;
188 limit_req zone=tarpit burst=5;
189 limit_req zone=reverse burst=5;
190 limit_req_status 429;
191 fastcgi_pass nominatim_service;
192 include fastcgi_params;
193 fastcgi_param QUERY_STRING $args;
194 fastcgi_param PATH_INFO "$nominatim_path_info";
195 fastcgi_param SCRIPT_FILENAME "$document_root/$nominatim_script_name";
196 if ($forward_to_ui) {
197 rewrite ^(/[^/]*) https://$host/ui$1.html redirect;
202 if ($blocked_user_agent ~ ^2$)
204 if ($blocked_referrer)
208 include <%= @confdir %>/nginx_blocked_generic.conf;
210 limit_req zone=www burst=10;
211 limit_req zone=tarpit burst=2;
212 limit_req zone=reverse burst=5;
213 limit_req_status 429;
214 fastcgi_pass nominatim_service;
215 include fastcgi_params;
216 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
218 if ($forward_to_ui) {
219 rewrite (.*).php https://$host/ui$1.html redirect;