]> git.openstreetmap.org Git - chef.git/blob - cookbooks/imagery/templates/default/nginx_titiler.conf.erb
e849484418b5606dc8827d7296063410e9298ed7
[chef.git] / cookbooks / imagery / templates / default / nginx_titiler.conf.erb
1 server {
2     listen 80;
3     listen [::]:80;
4     server_name <%= @name %> <% @aliases.each do |alias_name| %> <%= alias_name %><%- end -%>;
5
6     rewrite ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 permanent;
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     }
16 }
17
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
26 server {
27     listen 443 ssl http2;
28     listen [::]:443 ssl http2;
29     server_name <%= @name %> <% @aliases.each do |alias_name| %> <%= alias_name %><%- end -%>;
30
31     ssl_certificate /etc/ssl/certs/<%= @name %>.pem;
32     ssl_certificate_key /etc/ssl/private/<%= @name %>.key;
33 <% if node[:ssl][:strict_transport_security] -%>
34
35     add_header Strict-Transport-Security "<%= node[:ssl][:strict_transport_security] %>" always;
36 <% end -%>
37
38     # Requests sent within early data are subject to replay attacks.
39     # See: http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_early_data
40     ssl_early_data on;
41
42     # root "/srv/<%= @name %>";
43
44     gzip on;
45     gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml image/svg+xml; # text/html is implicit
46     gzip_min_length 512;
47     gzip_http_version 1.0;
48     gzip_proxied any;
49     gzip_comp_level 9;
50     gzip_vary on;
51
52     location /za-25cm {
53       root "/store/imagery/za";
54       expires max;
55     }
56
57     location /api/v1/titiler {
58       rewrite ^/api/v1/titiler(.*)$ $1 break;
59       proxy_pass http://localhost:8080;
60       proxy_set_header Host $host;
61       proxy_set_header Referer $http_referer;
62       proxy_set_header X-Forwarded-For $remote_addr;
63       proxy_set_header X-Forwarded-Proto https;
64       proxy_set_header X-Forwarded-SSL on;
65       proxy_http_version 1.1;
66       proxy_set_header "Connection" "";
67       proxy_redirect off;
68     }
69
70     location /ngi-aerial {
71       set $args "";
72       rewrite ^/ngi-aerial/(\d+)/(\d+)/(\d+)\.jpg  /mosaicjson/tiles/WebMercatorQuad/$1/$2/$3@1x?url=https%3A%2F%2Ftiler.openstreetmap.org%2Fza-25cm%2Fmosaic-tiler-https.json&pixel_selection=first&tile_format=jpeg break;
73       proxy_pass http://tiler_backend;
74       proxy_set_header Host $host;
75       proxy_set_header Referer $http_referer;
76       proxy_set_header X-Forwarded-For $remote_addr;
77       proxy_set_header X-Forwarded-Proto https;
78       proxy_set_header X-Forwarded-SSL on;
79       proxy_http_version 1.1;
80       proxy_set_header "Connection" "";
81       proxy_redirect off;
82       proxy_cache_key "$scheme$proxy_host$uri";
83       proxy_cache ngi-aerial;
84       proxy_cache_valid 200 204 180d;
85       proxy_cache_use_stale error timeout updating http_502 http_503 http_504;
86       proxy_cache_background_update on;
87       proxy_ignore_headers Cache-Control;
88       expires max;
89       add_header X-Proxy-Cache $upstream_cache_status;
90
91     }
92 }