1 upstream nominatim_service {
2 server 127.0.0.1:<%= @pools[:www][:port ]%>;
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;
29 map $query_string $email_id {
30 ~(^|&)email=([^&]+) $2;
33 map $email_id $missing_email {
38 map $http_user_agent $missing_ua {
43 map $http_referer $missing_referer {
51 <% @frontends.each do |frontend| -%>
52 <% frontend.ipaddresses(:role => :external).sort.each do |address| -%>
62 map $missing_email$missing_referer$http_user_agent $blocked_user_agent {
64 "11" 2; # block any requests without identifier
65 include <%= @confdir %>/nginx_blocked_user_agent.conf;
68 map $missing_email$missing_ua$http_referer $blocked_referrer {
70 include <%= @confdir %>/nginx_blocked_referrer.conf;
73 map $missing_referer$missing_ua$email_id $blocked_email {
75 include <%= @confdir %>/nginx_blocked_email.conf;
78 map $whitelisted $limit_www {
80 0 $binary_remote_addr;
83 map $blocked_user_agent $limit_tarpit {
85 1 $binary_remote_addr;
86 2 $binary_remote_addr;
89 map $missing_email$missing_referer$http_user_agent $generic_mozilla {
95 map $whitelisted$generic_mozilla$uri $limit_reverse {
97 ~01/reverse.* $binary_remote_addr;
98 ~02/reverse.* $binary_remote_addr;
101 limit_req_zone $limit_www zone=www:50m rate=2r/s;
102 limit_req_zone $limit_tarpit zone=tarpit:10m rate=1r/s;
103 limit_req_zone $binary_remote_addr zone=blocked:10m rate=20r/m;
104 limit_req_zone $limit_reverse zone=reverse:10m rate=10r/m;
107 listen 80 default_server;
108 listen [::]:80 default_server;
110 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
111 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
113 location /nginx_status {
121 rewrite ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 permanent;
124 return 301 https://$host$request_uri;
130 listen 443 ssl deferred backlog=16384 reuseport http2 default_server;
132 listen [::]:443 ssl deferred backlog=16384 reuseport http2 default_server;
133 server_name localhost;
135 ssl_certificate /etc/ssl/certs/<%= node[:fqdn] %>.pem;
136 ssl_certificate_key /etc/ssl/private/<%= node[:fqdn] %>.key;
138 root <%= @directory %>/website;
141 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
142 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
144 location /nginx_status {
152 error_page 403 /403.html;
154 limit_req zone=blocked burst=5;
157 error_page 429 /509.html;
159 limit_req zone=blocked burst=5;
163 try_files $uri $uri/ @php;
167 alias <%= @ui_directory %>/dist/;
172 if ($blocked_user_agent ~ ^2$)
174 if ($blocked_referrer)
178 include <%= @confdir %>/nginx_blocked_generic.conf;
180 limit_req zone=www burst=10;
181 limit_req zone=tarpit burst=2;
182 limit_req zone=reverse burst=5;
183 limit_req_status 429;
184 fastcgi_pass nominatim_service;
185 include fastcgi_params;
186 fastcgi_param QUERY_STRING $args;
187 fastcgi_param PATH_INFO "$nominatim_path_info";
188 fastcgi_param SCRIPT_FILENAME "$document_root/$nominatim_script_name";
189 if ($forward_to_ui) {
190 rewrite ^(/[^/]*) https://$host/ui$1.html redirect;
195 if ($blocked_user_agent ~ ^2$)
197 if ($blocked_referrer)
201 include <%= @confdir %>/nginx_blocked_generic.conf;
203 limit_req zone=www burst=10;
204 limit_req zone=tarpit burst=2;
205 limit_req zone=reverse burst=5;
206 limit_req_status 429;
207 fastcgi_pass nominatim_service;
208 include fastcgi_params;
209 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
211 if ($forward_to_ui) {
212 rewrite (.*).php https://$host/ui$1.html redirect;