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 # Do not pass cookies to backends.
57 proxy_set_header Cookie '';
58 # Do not pass Accept-Encoding to backends.
59 proxy_set_header Accept-Encoding '';
61 # Do not allow setting cookies from backends due to caching.
62 proxy_ignore_headers Set-Cookie;
63 proxy_hide_header Set-Cookie;
65 # Set a QoS cookie if none presented (uses nginx Map)
66 add_header Set-Cookie $cookie_qos_token_set;
67 <% if node[:ssl][:strict_transport_security] -%>
68 # Ensure Strict-Transport-Security header is removed from proxied server responses
69 proxy_hide_header Strict-Transport-Security;
72 add_header Strict-Transport-Security "<%= node[:ssl][:strict_transport_security] %>" always;
75 # QoS Traffic Rate see $limit_rate on http://nginx.org/en/docs/http/ngx_http_core_module.html
76 set $limit_rate $limit_rate_qos;
78 # Allow Higher Traffic Rate from Approved User-Agents which do not support cookies (uses nginx Map)
79 if ($approved_scraper) {
80 set $limit_rate 32768;
83 # Strip any ?query parameters from urls
86 # Allow cache purging headers only from select User-Agents (uses nginx Map)
87 proxy_set_header Cache-Control $limit_http_cache_control;
88 proxy_set_header Pragma $limit_http_pragma;