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) 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 limit_req_zone $limit_www zone=www:50m rate=2r/s;
90 limit_req_zone $limit_tarpit zone=tarpit:10m rate=1r/s;
91 limit_req_zone $binary_remote_addr zone=blocked:10m rate=20r/m;
94 listen 80 default_server;
95 listen [::]:80 default_server;
97 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
98 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
100 location /nginx_status {
108 rewrite ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 permanent;
111 return 301 https://$host$request_uri;
117 listen 443 ssl deferred backlog=16384 reuseport http2 default_server;
119 listen [::]:443 ssl deferred backlog=16384 reuseport http2 default_server;
120 server_name localhost;
122 ssl_certificate /etc/ssl/certs/<%= node[:fqdn] %>.pem;
123 ssl_certificate_key /etc/ssl/private/<%= node[:fqdn] %>.key;
125 root <%= @directory %>/website;
128 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
129 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
131 location /nginx_status {
139 error_page 403 /403.html;
141 limit_req zone=blocked burst=5;
144 error_page 429 /509.html;
146 limit_req zone=blocked burst=5;
150 try_files $uri $uri/ @php;
154 alias <%= @ui_directory %>/dist/;
159 if ($blocked_user_agent ~ ^2$)
161 if ($blocked_referrer)
165 include <%= @confdir %>/nginx_blocked_generic.conf;
167 limit_req zone=www burst=10;
168 limit_req zone=tarpit burst=2;
169 limit_req_status 429;
170 fastcgi_pass nominatim_service;
171 include fastcgi_params;
172 fastcgi_param QUERY_STRING $args;
173 fastcgi_param PATH_INFO "$nominatim_path_info";
174 fastcgi_param SCRIPT_FILENAME "$document_root/$nominatim_script_name";
175 if ($forward_to_ui) {
176 rewrite ^(/[^/]*) https://$host/ui$1.html redirect;
181 if ($blocked_user_agent ~ ^2$)
183 if ($blocked_referrer)
187 include <%= @confdir %>/nginx_blocked_generic.conf;
189 limit_req zone=www burst=10;
190 limit_req zone=tarpit burst=2;
191 limit_req_status 429;
192 fastcgi_pass nominatim_service;
193 include fastcgi_params;
194 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
196 if ($forward_to_ui) {
197 rewrite (.*).php https://$host/ui$1.html redirect;