1 upstream nominatim_service {
2 server unix:/run/gunicorn-nominatim.openstreetmap.org.sock fail_timeout=0;
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
66 34.234.151.67 1; # gnome - https://github.com/openstreetmap/operations/issues/1160
67 54.165.53.199 1; # gnome - https://github.com/openstreetmap/operations/issues/1160
68 35.153.15.118 1; # gnome - https://github.com/openstreetmap/operations/issues/1160
71 map $server_protocol$http_user_agent $cleaned_user_agent {
72 default $http_user_agent;
73 "~^HTTP/1..Mozilla/" Script$http_user_agent;
76 map $missing_email$missing_referer$cleaned_user_agent $blocked_user_agent {
78 "11" 2; # block any requests without identifier
79 include <%= @confdir %>/nginx_blocked_user_agent.conf;
82 map $missing_email$missing_ua$http_referer $blocked_referrer {
84 include <%= @confdir %>/nginx_blocked_referrer.conf;
87 map $missing_referer$missing_ua$email_id $blocked_email {
89 include <%= @confdir %>/nginx_blocked_email.conf;
92 map $whitelisted $limit_www {
94 0 $binary_remote_addr;
97 map $blocked_user_agent $limit_tarpit {
99 1 $binary_remote_addr;
100 2 $binary_remote_addr;
103 map $missing_email$missing_referer$http_user_agent $generic_mozilla {
109 map $whitelisted$generic_mozilla$uri $limit_reverse {
111 ~01/reverse.* $binary_remote_addr;
112 ~02/reverse.* $binary_remote_addr;
115 limit_req_zone $limit_www zone=www:50m rate=2r/s;
116 limit_req_zone $limit_tarpit zone=tarpit:10m rate=1r/s;
117 limit_req_zone $binary_remote_addr zone=blocked:10m rate=20r/m;
118 limit_req_zone $limit_reverse zone=reverse:10m rate=10r/m;
121 listen 80 default_server;
122 listen [::]:80 default_server;
124 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
125 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
127 location /nginx_status {
135 rewrite ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 permanent;
138 return 301 https://$host$request_uri;
144 listen 443 ssl http2 default_server;
146 listen [::]:443 ssl http2 default_server;
147 server_name localhost;
149 ssl_certificate /etc/ssl/certs/<%= node[:fqdn] %>.pem;
150 ssl_certificate_key /etc/ssl/private/<%= node[:fqdn] %>.key;
152 root <%= @directory %>/static-website;
155 access_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-access.log combined;
156 error_log <%= node[:nominatim][:logdir] %>/nominatim.openstreetmap.org-error.log;
158 location /nginx_status {
166 error_page 403 /403.html;
168 limit_req zone=blocked burst=5;
171 error_page 429 /509.html;
173 limit_req zone=blocked burst=5;
177 try_files $uri $uri/ @php;
181 alias <%= @ui_directory %>/dist/;
186 add_header Access-Control-Allow-Origin "*" always;
189 location ~* ^/(search|reverse)(\.php)?/ {
190 error_page 404 /404-old-search-syntax.html;
195 if ($forward_to_ui) {
196 rewrite ^(/[^/]*) https://$host/ui$1.html redirect;
198 if ($blocked_user_agent ~ ^2$)
200 if ($blocked_referrer)
204 if ($args ~* "q=[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[ &]")
206 include <%= @confdir %>/nginx_blocked_generic.conf;
208 limit_req zone=www burst=10;
209 limit_req zone=tarpit burst=5;
210 limit_req zone=reverse burst=5;
211 limit_req_status 429;
213 if ($request_method = 'OPTIONS') {
214 add_header 'Content-Type' 'text/plain; charset=UTF-8';
215 add_header 'Content-Length' 0;
216 add_header Access-Control-Allow-Origin "*";
217 add_header Access-Control-Allow-Methods 'GET,OPTIONS';
218 add_header Access-Control-Allow-Headers $http_access_control_request_headers;
222 proxy_set_header Host $http_host;
223 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
224 proxy_set_header X-Forwarded-Proto $scheme;
226 proxy_pass http://nominatim_service;