Merge pull request #3765 from lonvia/update-ui-docs

Update instructions for UI integration
This commit is contained in:
Sarah Hoffmann
2025-06-27 20:01:28 +02:00
committed by GitHub

View File

@@ -36,11 +36,11 @@ The website is now available at `http://localhost:8765`.
## Forwarding searches to nominatim-ui ## Forwarding searches to nominatim-ui
Nominatim used to provide the search interface directly by itself when Nominatim used to provide the search interface directly by itself when
`format=html` was requested. For all endpoints except for `/reverse` and `format=html` was requested. For the `/search` endpoint this even used
`/lookup` this even used to be the default. to be the default.
The following section describes how to set up Apache or nginx, so that your 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. the UI.
### Setting up forwarding in Nginx ### 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. # Determine from the URI and the format parameter above if forwarding is needed.
map $uri/$format $forward_to_ui { map $uri/$format $forward_to_ui {
default 1; # The default is to forward. default 0; # no forwarding by default
~^/ui 0; # If the URI point to the UI already, we are done. ~/search.*/default 1; # Use this line only, if search should go to UI by default.
~/other$ 0; # An explicit non-html format parameter. No forwarding. ~/reverse.*/html 1; # Forward API calls that UI supports, when
~/reverse.*/default 0; # Reverse and lookup assume xml format when ~/status.*/html 1; # format=html is explicitly requested.
~/lookup.*/default 0; # no format parameter is given. No forwarding. ~/search.*/html 1;
~/details.*/html 1;
} }
``` ```
The `$forward_to_ui` parameter can now be used to conditionally forward the The `$forward_to_ui` parameter can now be used to conditionally forward the
calls: calls:
``` ``` nginx
# When no endpoint is given, default to search. location / {
# Need to add a rewrite so that the rewrite rules below catch it correctly.
rewrite ^/$ /search;
location @php {
# fastcgi stuff..
if ($forward_to_ui) { if ($forward_to_ui) {
rewrite ^(/[^/]*) https://yourserver.com/ui$1.html redirect; rewrite ^(/[^/.]*) https://$http_host/ui$1.html redirect;
} }
}
location ~ [^/]\.php(/|$) { # proxy_pass commands
# fastcgi stuff..
if ($forward_to_ui) {
rewrite (.*).php https://yourserver.com/ui$1.html redirect;
}
} }
``` ```
!!! 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. Reload nginx and the UI should be available.
### Setting up forwarding in Apache ### Setting up forwarding in Apache
@@ -159,18 +146,16 @@ directory like this:
RewriteBase "/nominatim/" RewriteBase "/nominatim/"
# If no endpoint is given, then use search. # If no endpoint is given, then use search.
RewriteRule ^(/|$) "search.php" RewriteRule ^(/|$) "search"
# If format-html is explicitly requested, forward to the UI. # If format-html is explicitly requested, forward to the UI.
RewriteCond %{QUERY_STRING} "format=html" 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 # Optionally: if no format parameter is there then forward /search.
# but /reverse and /lookup to the UI.
RewriteCond %{QUERY_STRING} "!format=" RewriteCond %{QUERY_STRING} "!format="
RewriteCond %{REQUEST_URI} "!/lookup" RewriteCond %{REQUEST_URI} "/search"
RewriteCond %{REQUEST_URI} "!/reverse" RewriteRule ^([^/.]+) ui/$1.html [R,END]
RewriteRule ^([^/]+)(.php)? ui/$1.html [R,END]
</Directory> </Directory>
``` ```