1 # DO NOT EDIT - This file is being maintained by Chef
3 upstream tile_cache_backend {
9 # Rates table based on current cookie value
10 map $cookie_qos_token $limit_rate_qos {
11 include /etc/nginx/conf.d/tile_qos_rates.map;
14 # Set-Cookie table based on current cookie value
15 map $cookie_qos_token $cookie_qos_token_set {
16 include /etc/nginx/conf.d/tile_qos_cookies.map;
19 map $http_user_agent $approved_scraper {
20 default ''; # Not approved
22 '~^Mozilla\/5\.0\ QGIS\/' 'QGIS';
25 # Limit Cache-Control header to only approved User-Agents
26 map $http_user_agent $limit_http_cache_control {
27 default ''; # Unset Header
28 '~^Mozilla\/5\.0\ QGIS\/' ''; # Unset Header
29 '~^Mozilla\/5\.0\ ' $http_cache_control; # Pass Header
32 # Limit Pragma header to only approved User-Agents
33 map $http_user_agent $limit_http_pragma {
34 default ''; # Unset Header
35 '~^Mozilla\/5\.0\ QGIS\/' ''; # Unset Header
36 '~^Mozilla\/5\.0\ ' $http_pragma; # Pass Header
40 listen 443 ssl fastopen=2048 http2 default_server;
41 server_name localhost;
45 ssl_certificate /etc/ssl/certs/tile.openstreetmap.org.pem;
46 ssl_certificate_key /etc/ssl/private/tile.openstreetmap.org.key;
49 proxy_pass http://tile_cache_backend;
50 proxy_set_header X-Forwarded-For $remote_addr;
51 proxy_http_version 1.1;
52 proxy_set_header Connection '';
54 proxy_connect_timeout 5s;
56 # Preserve host header.
57 proxy_set_header Host $host;
58 # Do not pass cookies to backends.
59 proxy_set_header Cookie '';
60 # Do not pass Accept-Encoding to backends.
61 proxy_set_header Accept-Encoding '';
63 # Do not allow setting cookies from backends due to caching.
64 proxy_ignore_headers Set-Cookie;
65 proxy_hide_header Set-Cookie;
67 # Set a QoS cookie if none presented (uses nginx Map)
68 add_header Set-Cookie $cookie_qos_token_set;
69 <% if node[:ssl][:strict_transport_security] -%>
70 # Ensure Strict-Transport-Security header is removed from proxied server responses
71 proxy_hide_header Strict-Transport-Security;
74 add_header Strict-Transport-Security "<%= node[:ssl][:strict_transport_security] %>" always;
77 # QoS Traffic Rate see $limit_rate on http://nginx.org/en/docs/http/ngx_http_core_module.html
78 set $limit_rate $limit_rate_qos;
80 # Allow Higher Traffic Rate from Approved User-Agents which do not support cookies (uses nginx Map)
81 if ($approved_scraper) {
82 set $limit_rate 32768;
85 # Strip any ?query parameters from urls
88 # Allow cache purging headers only from select User-Agents (uses nginx Map)
89 proxy_set_header Cache-Control $limit_http_cache_control;
90 proxy_set_header Pragma $limit_http_pragma;