default_ssl.j2 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. server {
  2. listen 443 ssl;
  3. listen [::]:443 ssl;
  4. server_name {{inventory_hostname_short}}.{{freifunk.domain_short}} karte.freifunk-dortmund.de;
  5. ssl_certificate /etc/ssl/fullchain.pem;
  6. ssl_certificate_key /etc/ssl/key.pem;
  7. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  8. ssl_prefer_server_ciphers on;
  9. ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
  10. ssl_ecdh_curve secp384r1;
  11. ssl_session_cache shared:SSL:10m;
  12. ssl_session_tickets off;
  13. ssl_stapling on;
  14. ssl_stapling_verify on;
  15. resolver 8.8.8.8 8.8.4.4 valid=300s;
  16. resolver_timeout 5s;
  17. add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
  18. add_header X-Content-Type-Options nosniff;
  19. ssl_dhparam /etc/ssl/certs/dhparam.pem;
  20. root /var/www/html;
  21. location / {
  22. # redirect into directory to get correct docroot
  23. rewrite "^/map([0-9]{2})$" /map$1/ permanent;
  24. rewrite "^/map_([^/]+)$" /map$1/ permanent;
  25. # rewrite config.json to special path
  26. rewrite "^/map([0-9]{2})/config.json$" /map/config/config_$1.json break;
  27. rewrite "^/map_([^/]+)/config.json$" /map/config/config_$1.json break;
  28. # rewrite all other
  29. rewrite "^/map[0-9]{2}/(.*)$" /map/$1 break;
  30. rewrite "^/map_[^/]+/(.*)$" /map/$1 break;
  31. # First attempt to serve request as file, then
  32. # as directory, then fall back to displaying a 404.
  33. try_files $uri $uri/ =404;
  34. # enable gzip compression
  35. gzip on;
  36. gzip_http_version 1.0;
  37. gzip_vary on;
  38. gzip_comp_level 2;
  39. gzip_proxied any;
  40. gzip_types text/plain text/css text/javascript application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss;
  41. }
  42. # Proxy for mapdata
  43. location /data/ {
  44. # mapdata foreach domain, because hopglass can't handle args in uri)
  45. rewrite "^/data/map_([^/]+)/(.+)$" /$2?filter=site&value=$1 break;
  46. proxy_set_header Host $host;
  47. proxy_set_header X-Real-IP $remote_addr;
  48. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  49. proxy_set_header X-Forwarded-Proto $scheme;
  50. proxy_pass http://127.0.0.1:4000/;
  51. proxy_redirect off;
  52. proxy_cache hopglass;
  53. proxy_cache_valid 2m;
  54. # enable gzip compression
  55. gzip on;
  56. gzip_http_version 1.0;
  57. gzip_vary on;
  58. gzip_comp_level 4;
  59. gzip_proxied any;
  60. gzip_types text/plain text/css text/javascript application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss;
  61. }
  62. {% if nginx_tiles_cache is defined and 'instances' in nginx_tiles_cache %}
  63. {% for instance in nginx_tiles_cache.instances %}
  64. # tiles cache for {{instance.name}}
  65. location {{instance.location}} {
  66. proxy_set_header Host $host;
  67. proxy_set_header X-Real-IP $remote_addr;
  68. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  69. proxy_set_header X-Forwarded-Proto $scheme;
  70. proxy_pass {{instance.dest_url}};
  71. proxy_redirect off;
  72. proxy_cache {{instance.cache_location_name}};
  73. proxy_cache_valid {{instance.valid_time}};
  74. }
  75. {% endfor %}
  76. {% endif %}
  77. }