Skip to content

Commit e7928dc

Browse files
committedMar 18, 2024
imagery: add ngi-aerial code
1 parent c1c86ec commit e7928dc

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed
 

‎cookbooks/imagery/recipes/tiler.rb

+6
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
:FORWARDED_ALLOW_IPS => "*" # https://docs.gunicorn.org/en/latest/settings.html#forwarded-allow-ips
4646
end
4747

48+
directory "/var/cache/nginx-cache" do
49+
owner "www-data"
50+
group "www-data"
51+
mode "755"
52+
end
53+
4854
ssl_certificate "tiler.openstreetmap.org" do
4955
domains "tiler.openstreetmap.org"
5056
notifies :reload, "service[nginx]"

‎cookbooks/imagery/templates/default/nginx_titiler.conf.erb

+40-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,25 @@ server {
44
server_name <%= @name %> <% @aliases.each do |alias_name| %> <%= alias_name %><%- end -%>;
55

66
rewrite ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 permanent;
7-
return 301 https://$host$request_uri;
7+
8+
location / {
9+
return 301 https://$host$request_uri;
10+
}
11+
12+
location /za-25cm {
13+
root "/store/imagery/za";
14+
expires max;
15+
}
816
}
917

18+
upstream tiler_backend {
19+
server 127.0.0.1:8080;
20+
21+
keepalive 32;
22+
}
23+
24+
proxy_cache_path /var/cache/nginx-cache levels=1:2 keys_zone=ngi-aerial:64m;
25+
1026
server {
1127
listen 443 ssl http2;
1228
listen [::]:443 ssl http2;
@@ -33,6 +49,11 @@ server {
3349
gzip_comp_level 9;
3450
gzip_vary on;
3551

52+
location /za-25cm {
53+
root "/store/imagery/za";
54+
expires max;
55+
}
56+
3657
location /api/v1/titiler {
3758
rewrite ^/api/v1/titiler(.*)$ $1 break;
3859
proxy_pass http://localhost:8080;
@@ -41,6 +62,24 @@ server {
4162
proxy_set_header X-Forwarded-For $remote_addr;
4263
proxy_set_header X-Forwarded-Proto https;
4364
proxy_set_header X-Forwarded-SSL on;
65+
proxy_http_version 1.1;
66+
proxy_redirect off;
67+
}
68+
69+
location /ngi-aerial {
70+
set $args "";
71+
rewrite ^/ngi-aerial/(\d+)/(\d+)/(\d+)\.jpg /mosaicjson/tiles/WebMercatorQuad/$1/$2/$3@1x?url=http%3A%2F%2Ftiler.openstreetmap.org%2Fza-25cm%2Fmosaic-tiler.json&pixel_selection=first&tile_format=jpeg break;
72+
proxy_pass http://tiler_backend;
73+
proxy_set_header Host $host;
74+
proxy_set_header Referer $http_referer;
75+
proxy_set_header X-Forwarded-For $remote_addr;
76+
proxy_set_header X-Forwarded-Proto https;
77+
proxy_set_header X-Forwarded-SSL on;
78+
proxy_http_version 1.1;
4479
proxy_redirect off;
80+
proxy_cache_key "$scheme$proxy_host$uri";
81+
proxy_cache ngi-aerial;
82+
proxy_cache_valid any 90d;
83+
expires max;
4584
}
4685
}

0 commit comments

Comments
 (0)