1 # Setting up the Nominatim UI
3 Nominatim is a search API, it does not provide a website interface on its
4 own. [nominatim-ui](https://github.com/osm-search/nominatim-ui) offers a
5 small website for testing your setup and inspecting the database content.
7 This section provides a quick start how to use nominatim-ui with your
8 installation. For more details, please also have a look at the
9 [README of nominatim-ui](https://github.com/osm-search/nominatim-ui/blob/master/README.md).
11 ## Installing nominatim-ui
13 We provide regular releases of nominatim-ui that contain the packaged website.
14 They do not need any special installation. Just download, configure
15 and run it. Grab the latest release from
16 [nominatim-ui's Github release page](https://github.com/osm-search/nominatim-ui/releases)
17 and unpack it. You can use `nominatim-ui-x.x.x.tar.gz` or `nominatim-ui-x.x.x.zip`.
19 Copy the example configuration into the right place:
22 cp dist/config.example.js dist/config.js
24 Now adapt the configuration to your needs. You need at least
25 to change the `Nominatim_API_Endpoint` to point to your Nominatim installation.
27 Then you can just test it locally by spinning up a webserver in the `dist`
28 directory. For example, with Python:
31 python3 -m http.server 8765
33 The website is now available at `http://localhost:8765`.
35 ## Forwarding searches to nominatim-ui
37 Nominatim used to provide the search interface directly by itself when
38 `format=html` was requested. For all endpoints except for `/reverse` and
39 `/lookup` this even used to be the default.
41 The following section describes how to set up Apache or nginx, so that your
42 users are forwarded to nominatim-ui when they go to URL that formerly presented
45 ### Setting up forwarding in Nginx
47 First of all make nominatim-ui available under `/ui` on your webserver:
52 # Here is the Nominatim setup as described in the Installation section
55 alias <full path to the nominatim-ui directory>/dist/;
61 Now we need to find out if a URL should be forwarded to the UI. Add the
62 following `map` commands *outside* the server section:
65 # Inspect the format parameter in the query arguments. We are interested
66 # if it is set to html or something else or if it is missing completely.
69 ~(^|&)format=html(&|$) html;
73 # Determine from the URI and the format parameter above if forwarding is needed.
74 map $uri/$format $forward_to_ui {
75 default 1; # The default is to forward.
76 ~^/ui 0; # If the URI point to the UI already, we are done.
77 ~/other$ 0; # An explicit non-html format parameter. No forwarding.
78 ~/reverse.*/default 0; # Reverse and lookup assume xml format when
79 ~/lookup.*/default 0; # no format parameter is given. No forwarding.
83 The `$forward_to_ui` parameter can now be used to conditionally forward the
87 # When no endpoint is given, default to search.
88 # Need to add a rewrite so that the rewrite rules below catch it correctly.
94 rewrite ^(/[^/]*) https://yourserver.com/ui$1.html redirect;
98 location ~ [^/]\.php(/|$) {
100 if ($forward_to_ui) {
101 rewrite (.*).php https://yourserver.com/ui$1.html redirect;
107 Be aware that the rewrite commands are slightly different for URIs with and
108 without the .php suffix.
110 Reload nginx and the UI should be available.
112 ### Setting up forwarding in Apache
114 First of all make nominatim-ui available in the `ui/` subdirectory where
115 Nominatim is installed. For example, given you have set up an alias under
116 `nominatim` like this:
119 Alias /nominatim /home/vagrant/build/website
122 you need to insert the following rules for nominatim-ui before that alias:
125 <Directory "/home/vagrant/nominatim-ui/dist">
126 DirectoryIndex search.html
130 Alias /nominatim/ui /home/vagrant/nominatim-ui/dist
133 Replace `/home/vagrant/nominatim-ui` with the directory where you have cloned
137 The alias for nominatim-ui must come before the alias for the Nominatim
140 To set up forwarding, the Apache rewrite module is needed. Enable it with:
146 Then add rewrite rules to the `Directory` directive of the Nominatim website
150 <Directory "/home/vagrant/build/website">
151 Options FollowSymLinks MultiViews
152 AddType text/html .php
157 # This must correspond to the URL where nominatim can be found.
158 RewriteBase "/nominatim/"
160 # If no endpoint is given, then use search.
161 RewriteRule ^(/|$) "search.php"
163 # If format-html is explicity requested, forward to the UI.
164 RewriteCond %{QUERY_STRING} "format=html"
165 RewriteRule ^([^/]+).php ui/$1.html [R,END]
166 # Same but .php suffix is missing.
167 RewriteCond %{QUERY_STRING} "format=html"
168 RewriteRule ^([^/]+) ui/$1.html [R,END]
170 # If no format parameter is there then forward anything
171 # but /reverse and /lookup to the UI.
172 RewriteCond %{QUERY_STRING} "!format="
173 RewriteCond %{REQUEST_URI} "!/lookup"
174 RewriteCond %{REQUEST_URI} "!/reverse"
175 RewriteRule ^([^/]+).php ui/$1.html [R,END]
176 # Same but .php suffix is missing.
177 RewriteCond %{QUERY_STRING} "!format="
178 RewriteCond %{REQUEST_URI} "!/lookup"
179 RewriteCond %{REQUEST_URI} "!/reverse"
180 RewriteRule ^([^/]+) ui/$1.html [R,END]
184 Restart Apache and the UI should be available.