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 Next you need to adapt the UI to your installation. Custom settings need to be
20 put into `dist/theme/config.theme.js`. At a minimum you need to
21 set `Nominatim_API_Endpoint` to point to your Nominatim installation:
24 echo "Nominatim_Config.Nominatim_API_Endpoint='https://myserver.org/nominatim/';" > dist/theme/config.theme.js
26 For the full set of available settings, have a look at `dist/config.defaults.js`.
28 Then you can just test it locally by spinning up a webserver in the `dist`
29 directory. For example, with Python:
32 python3 -m http.server 8765
34 The website is now available at `http://localhost:8765`.
36 ## Forwarding searches to nominatim-ui
38 Nominatim used to provide the search interface directly by itself when
39 `format=html` was requested. For all endpoints except for `/reverse` and
40 `/lookup` this even used to be the default.
42 The following section describes how to set up Apache or nginx, so that your
43 users are forwarded to nominatim-ui when they go to URL that formerly presented
46 ### Setting up forwarding in Nginx
48 First of all make nominatim-ui available under `/ui` on your webserver:
53 # Here is the Nominatim setup as described in the Installation section
56 alias <full path to the nominatim-ui directory>/dist/;
62 Now we need to find out if a URL should be forwarded to the UI. Add the
63 following `map` commands *outside* the server section:
66 # Inspect the format parameter in the query arguments. We are interested
67 # if it is set to html or something else or if it is missing completely.
70 ~(^|&)format=html(&|$) html;
74 # Determine from the URI and the format parameter above if forwarding is needed.
75 map $uri/$format $forward_to_ui {
76 default 1; # The default is to forward.
77 ~^/ui 0; # If the URI point to the UI already, we are done.
78 ~/other$ 0; # An explicit non-html format parameter. No forwarding.
79 ~/reverse.*/default 0; # Reverse and lookup assume xml format when
80 ~/lookup.*/default 0; # no format parameter is given. No forwarding.
84 The `$forward_to_ui` parameter can now be used to conditionally forward the
88 # When no endpoint is given, default to search.
89 # Need to add a rewrite so that the rewrite rules below catch it correctly.
95 rewrite ^(/[^/]*) https://yourserver.com/ui$1.html redirect;
99 location ~ [^/]\.php(/|$) {
101 if ($forward_to_ui) {
102 rewrite (.*).php https://yourserver.com/ui$1.html redirect;
108 Be aware that the rewrite commands are slightly different for URIs with and
109 without the .php suffix.
111 Reload nginx and the UI should be available.
113 ### Setting up forwarding in Apache
115 First of all make nominatim-ui available in the `ui/` subdirectory where
116 Nominatim is installed. For example, given you have set up an alias under
117 `nominatim` like this:
120 Alias /nominatim /home/vagrant/build/website
123 you need to insert the following rules for nominatim-ui before that alias:
126 <Directory "/home/vagrant/nominatim-ui/dist">
127 DirectoryIndex search.html
131 Alias /nominatim/ui /home/vagrant/nominatim-ui/dist
134 Replace `/home/vagrant/nominatim-ui` with the directory where you have cloned
138 The alias for nominatim-ui must come before the alias for the Nominatim
141 To set up forwarding, the Apache rewrite module is needed. Enable it with:
147 Then add rewrite rules to the `Directory` directive of the Nominatim website
151 <Directory "/home/vagrant/build/website">
152 Options FollowSymLinks MultiViews
153 AddType text/html .php
158 # This must correspond to the URL where nominatim can be found.
159 RewriteBase "/nominatim/"
161 # If no endpoint is given, then use search.
162 RewriteRule ^(/|$) "search.php"
164 # If format-html is explicity requested, forward to the UI.
165 RewriteCond %{QUERY_STRING} "format=html"
166 RewriteRule ^([^/]+)(.php)? ui/$1.html [R,END]
168 # If no format parameter is there then forward anything
169 # but /reverse and /lookup to the UI.
170 RewriteCond %{QUERY_STRING} "!format="
171 RewriteCond %{REQUEST_URI} "!/lookup"
172 RewriteCond %{REQUEST_URI} "!/reverse"
173 RewriteRule ^([^/]+)(.php)? ui/$1.html [R,END]
177 Restart Apache and the UI should be available.