1 upstream nominatim_service {
2 server unix:/run/php/php-nominatim.openstreetmap.org-fpm.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| -%>
63 2620:52:3:1:5054:ff:fe0a:75a4 1; # gnome
64 2620:52:3:1:5054:ff:fe0a:75a2 1; # gnome
65 2620:52:3:1:5054:ff:fe0a:75aa 1; # gnome
68 map $missing_email$missing_referer$http_user_agent $blocked_user_agent {
70 "11" 2; # block any requests without identifier
71 include <%= @confdir %>/nginx_blocked_user_agent.conf;
74 map $missing_email$missing_ua$http_referer $blocked_referrer {
76 include <%= @confdir %>/nginx_blocked_referrer.conf;
79 map $missing_referer$missing_ua$email_id $blocked_email {
81 include <%= @confdir %>/nginx_blocked_email.conf;
84 map $whitelisted $limit_www {
86 0 $binary_remote_addr;
89 map $blocked_user_agent $limit_tarpit {
91 1 $binary_remote_addr;
92 2 $binary_remote_addr;
95 map $missing_email$missing_referer$http_user_agent $generic_mozilla {
101 map $whitelisted$generic_mozilla$uri $limit_reverse {
103 ~01/reverse.* $binary_remote_addr;
104 ~02/reverse.* $binary_remote_addr;
107 limit_req_zone $limit_www zone=www:50m rate=2r/s;
108 limit_req_zone $limit_tarpit zone=tarpit:10m rate=1r/s;
109 limit_req_zone $binary_remote_addr zone=blocked:10m rate=20r/m;
110 limit_req_zone $limit_reverse zone=reverse:10m rate=10r/m;
113 listen 80 default_server;
114 listen [::]:80 default_server;
116 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
117 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
119 location /nginx_status {
127 rewrite ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 permanent;
130 return 301 https://$host$request_uri;
136 listen 443 ssl http2 default_server;
138 listen [::]:443 ssl http2 default_server;
139 server_name localhost;
141 ssl_certificate /etc/ssl/certs/<%= node[:fqdn] %>.pem;
142 ssl_certificate_key /etc/ssl/private/<%= node[:fqdn] %>.key;
144 root <%= @directory %>/website;
147 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
148 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
150 location /nginx_status {
158 error_page 403 /403.html;
160 limit_req zone=blocked burst=5;
163 error_page 429 /509.html;
165 limit_req zone=blocked burst=5;
169 try_files $uri $uri/ @php;
173 alias <%= @ui_directory %>/dist/;
178 add_header Access-Control-Allow-Origin "*" always;
182 if ($blocked_user_agent ~ ^2$)
184 if ($blocked_referrer)
188 include <%= @confdir %>/nginx_blocked_generic.conf;
190 limit_req zone=www burst=10;
191 limit_req zone=tarpit burst=5;
192 limit_req zone=reverse burst=5;
193 limit_req_status 429;
194 fastcgi_pass nominatim_service;
195 include fastcgi_params;
196 fastcgi_param QUERY_STRING $args;
197 fastcgi_param PATH_INFO "$nominatim_path_info";
198 fastcgi_param SCRIPT_FILENAME "$document_root/$nominatim_script_name";
199 if ($forward_to_ui) {
200 rewrite ^(/[^/]*) https://$host/ui$1.html redirect;
205 if ($blocked_user_agent ~ ^2$)
207 if ($blocked_referrer)
211 include <%= @confdir %>/nginx_blocked_generic.conf;
213 limit_req zone=www burst=10;
214 limit_req zone=tarpit burst=2;
215 limit_req zone=reverse burst=5;
216 limit_req_status 429;
217 fastcgi_pass nominatim_service;
218 include fastcgi_params;
219 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
221 if ($forward_to_ui) {
222 rewrite (.*).php https://$host/ui$1.html redirect;