From c4dd0d4f95d773f55c7d04cf618baaf26ff60165 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Fri, 27 Jun 2025 09:53:29 +0200 Subject: [PATCH] update instructions for UI integration Switches from defaulting to forwarding to UI to only forwarding when requested. This avoids issues with auto-forwarding illegal URLs. Also adapts to the much simplified nginx configuration. --- docs/admin/Setup-Nominatim-UI.md | 51 +++++++++++--------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/docs/admin/Setup-Nominatim-UI.md b/docs/admin/Setup-Nominatim-UI.md index cab2d2ed..5eef94a0 100644 --- a/docs/admin/Setup-Nominatim-UI.md +++ b/docs/admin/Setup-Nominatim-UI.md @@ -36,11 +36,11 @@ The website is now available at `http://localhost:8765`. ## Forwarding searches to nominatim-ui Nominatim used to provide the search interface directly by itself when -`format=html` was requested. For all endpoints except for `/reverse` and -`/lookup` this even used to be the default. +`format=html` was requested. For the `/search` endpoint this even used +to be the default. The following section describes how to set up Apache or nginx, so that your -users are forwarded to nominatim-ui when they go to URL that formerly presented +users are forwarded to nominatim-ui when they go to a URL that formerly presented the UI. ### Setting up forwarding in Nginx @@ -73,41 +73,28 @@ map $args $format { # Determine from the URI and the format parameter above if forwarding is needed. map $uri/$format $forward_to_ui { - default 1; # The default is to forward. - ~^/ui 0; # If the URI point to the UI already, we are done. - ~/other$ 0; # An explicit non-html format parameter. No forwarding. - ~/reverse.*/default 0; # Reverse and lookup assume xml format when - ~/lookup.*/default 0; # no format parameter is given. No forwarding. + default 0; # no forwarding by default + ~/search.*/default 1; # Use this line only, if search should go to UI by default. + ~/reverse.*/html 1; # Forward API calls that UI supports, when + ~/status.*/html 1; # format=html is explicitly requested. + ~/search.*/html 1; + ~/details.*/html 1; } ``` The `$forward_to_ui` parameter can now be used to conditionally forward the calls: -``` -# When no endpoint is given, default to search. -# Need to add a rewrite so that the rewrite rules below catch it correctly. -rewrite ^/$ /search; - -location @php { - # fastcgi stuff.. +``` nginx +location / { if ($forward_to_ui) { - rewrite ^(/[^/]*) https://yourserver.com/ui$1.html redirect; + rewrite ^(/[^/.]*) https://$http_host/ui$1.html redirect; } -} -location ~ [^/]\.php(/|$) { - # fastcgi stuff.. - if ($forward_to_ui) { - rewrite (.*).php https://yourserver.com/ui$1.html redirect; - } + # proxy_pass commands } ``` -!!! warning - Be aware that the rewrite commands are slightly different for URIs with and - without the .php suffix. - Reload nginx and the UI should be available. ### Setting up forwarding in Apache @@ -159,18 +146,16 @@ directory like this: RewriteBase "/nominatim/" # If no endpoint is given, then use search. - RewriteRule ^(/|$) "search.php" + RewriteRule ^(/|$) "search" # If format-html is explicitly requested, forward to the UI. RewriteCond %{QUERY_STRING} "format=html" - RewriteRule ^([^/]+)(.php)? ui/$1.html [R,END] + RewriteRule ^([^/.]+) ui/$1.html [R,END] - # If no format parameter is there then forward anything - # but /reverse and /lookup to the UI. + # Optionally: if no format parameter is there then forward /search. RewriteCond %{QUERY_STRING} "!format=" - RewriteCond %{REQUEST_URI} "!/lookup" - RewriteCond %{REQUEST_URI} "!/reverse" - RewriteRule ^([^/]+)(.php)? ui/$1.html [R,END] + RewriteCond %{REQUEST_URI} "/search" + RewriteRule ^([^/.]+) ui/$1.html [R,END] ``` -- 2.39.5