default[:nominatim][:revision] = "master"
default[:nominatim][:enable_backup] = false
default[:nominatim][:enable_git_updates] = true
+default[:nominatim][:ui_repository] = "https://github.com/osm-search/nominatim-ui"
+default[:nominatim][:ui_revision] = "master"
default[:nominatim][:fpm_pools] = {
:www => {
source_directory = "#{basedir}/nominatim"
build_directory = "#{basedir}/bin"
+ui_directory = "#{basedir}/ui"
directory build_directory do
owner "nominatim"
:log_file => "#{node[:nominatim][:logdir]}/query.log"
end
+git ui_directory do
+ action :sync
+ repository node[:nominatim][:ui_repository]
+ revision node[:nominatim][:ui_revision]
+ user "nominatim"
+ group "nominatim"
+end
+
+template "#{ui_directory}/dist/config.js" do
+ source "ui-config.js.erb"
+ owner "nominatim"
+ group "nominatim"
+ mode 0o664
+end
+
if node[:nominatim][:flatnode_file]
directory File.dirname(node[:nominatim][:flatnode_file]) do
recursive true
directory build_directory
variables :pools => node[:nominatim][:fpm_pools],
:frontends => search(:node, "recipes:web\\:\\:frontend"),
- :confdir => "#{basedir}/etc"
+ :confdir => "#{basedir}/etc",
+ :ui_directory => ui_directory
end
template "/etc/logrotate.d/nginx" do
~^/([^/]+)(.*)$ $2;
}
+map $args $format {
+ default default;
+ ~(^|&)format=html(&|$) html;
+ ~(^|&)format= other;
+}
+
+map $uri/$format $forward_to_ui {
+ default 1;
+ ~^/ui 0;
+ ~/other$ 0;
+ ~/reverse.*/default 0;
+ ~/lookup.*/default 0;
+}
+
map $query_string $email_id {
~(^|&)email=([^&]+) $2;
}
try_files $uri $uri/ @php;
}
+ location /ui/ {
+ alias <%= @ui_directory %>/dist/;
+ index search.html;
+ }
+
location @php {
if ($blocked_user_agent ~ ^2$)
{ return 403; }
fastcgi_param QUERY_STRING $args;
fastcgi_param PATH_INFO "$nominatim_path_info";
fastcgi_param SCRIPT_FILENAME "$document_root/$nominatim_script_name";
+ if ($forward_to_ui) {
+ rewrite ^(/[^/]*) http://$host/ui$1.html redirect;
+ }
}
location ~* \.php$ {
fastcgi_pass nominatim_service;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+
+ if ($forward_to_ui) {
+ rewrite (.*).php http://$host/ui$1.html redirect;
+ }
}
}