1 # DO NOT EDIT - This file is being maintained by Chef
3 upstream tile_cache_backend {
5 <% @caches.each do |cache| -%>
6 <% if cache[:hostname] != node[:hostname] -%>
7 #Server <%= cache[:hostname] %>
8 <% cache.ipaddresses(:family => :inet, :role => :external).sort.each do |address| -%>
9 server <%= address %> backup;
17 # Rates table based on current cookie value
18 map $cookie_qos_token $limit_rate_qos {
19 include /etc/nginx/conf.d/tile_qos_rates.map;
22 # Set-Cookie table based on current cookie value
23 map $cookie_qos_token $cookie_qos_token_set {
24 include /etc/nginx/conf.d/tile_qos_cookies.map;
27 map $http_user_agent $approved_scraper {
28 default ''; # Not approved
30 '~^Mozilla\/5\.0\ QGIS\/' 'QGIS';
33 # Limit Cache-Control header to only approved User-Agents
34 map $http_user_agent $limit_http_cache_control {
35 default ''; # Unset Header
36 '~^Mozilla\/5\.0\ QGIS\/' ''; # Unset Header
37 '~^Mozilla\/5\.0\ ' $http_cache_control; # Pass Header
40 # Limit Pragma header to only approved User-Agents
41 map $http_user_agent $limit_http_pragma {
42 default ''; # Unset Header
43 '~^Mozilla\/5\.0\ QGIS\/' ''; # Unset Header
44 '~^Mozilla\/5\.0\ ' $http_pragma; # Pass Header
48 listen 443 ssl fastopen=2048 http2 default_server;
49 server_name localhost;
53 ssl_certificate /etc/ssl/certs/<%= @certificate %>.pem;
54 ssl_certificate_key /etc/ssl/private/<%= @certificate %>.key;
56 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
57 ssl_ciphers <%= node[:ssl][:ciphers] -%>;
58 ssl_prefer_server_ciphers on;
59 ssl_session_cache shared:SSL:50m;
60 ssl_session_timeout 30m;
62 ssl_dhparam /etc/ssl/certs/dhparam.pem;
63 resolver <%= @resolvers.join(" ") %>;
67 proxy_pass http://tile_cache_backend;
68 proxy_set_header X-Forwarded-For $remote_addr;
69 proxy_http_version 1.1;
70 proxy_set_header Connection '';
72 proxy_connect_timeout 5s;
74 # Do not pass cookies to backends.
75 proxy_set_header Cookie '';
76 # Do not pass Accept-Encoding to backends.
77 proxy_set_header Accept-Encoding '';
79 # Do not allow setting cookies from backends due to caching.
80 proxy_ignore_headers Set-Cookie;
81 proxy_hide_header Set-Cookie;
83 # Set a QoS cookie if none presented (uses nginx Map)
84 add_header Set-Cookie $cookie_qos_token_set;
86 # QoS Traffic Rate see $limit_rate on http://nginx.org/en/docs/http/ngx_http_core_module.html
87 set $limit_rate $limit_rate_qos;
89 # Allow Higher Traffic Rate from Approved User-Agents which do not support cookies (uses nginx Map)
90 if ($approved_scraper) {
91 set $limit_rate 32768;
94 # Strip any ?query parameters from urls
97 # Allow cache purging headers only from select User-Agents (uses nginx Map)
98 proxy_set_header Cache-Control $limit_http_cache_control;
99 proxy_set_header Pragma $limit_http_pragma;