Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

109 lines
3.6 KiB

  1. #jinja2: lstrip_blocks: "True"
  2. {% macro render_vhost_directives() %}
  3. gzip on;
  4. gzip_types text/plain application/json application/javascript text/css image/x-icon font/ttf image/gif;
  5. {% if matrix_nginx_proxy_hsts_preload_enabled %}
  6. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
  7. {% else %}
  8. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
  9. {% endif %}
  10. # duplicate X-Content-Type-Options & X-Frame-Options header
  11. # Enabled by grafana by default
  12. # add_header X-Content-Type-Options nosniff;
  13. # add_header X-Frame-Options SAMEORIGIN;
  14. add_header Referrer-Policy "strict-origin-when-cross-origin";
  15. {% if matrix_nginx_proxy_floc_optout_enabled %}
  16. add_header Permissions-Policy interest-cohort=() always;
  17. {% endif %}
  18. proxy_cookie_path / "/; HTTPOnly; Secure";
  19. {% for configuration_block in matrix_nginx_proxy_proxy_grafana_additional_server_configuration_blocks %}
  20. {{- configuration_block }}
  21. {% endfor %}
  22. location / {
  23. {% if matrix_nginx_proxy_enabled %}
  24. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  25. resolver {{ matrix_nginx_proxy_http_level_resolver }} valid=5s;
  26. set $backend "matrix-grafana:3000";
  27. proxy_pass http://$backend;
  28. {% else %}
  29. {# Generic configuration for use outside of our container setup #}
  30. proxy_pass http://127.0.0.1:3000;
  31. {% endif %}
  32. proxy_set_header Host $host;
  33. proxy_set_header X-Forwarded-For {{ matrix_nginx_proxy_x_forwarded_for }};
  34. }
  35. {% endmacro %}
  36. server {
  37. listen {{ 8080 if matrix_nginx_proxy_enabled else 80 }};
  38. listen [::]:{{ 8080 if matrix_nginx_proxy_enabled else 80 }};
  39. server_name {{ matrix_nginx_proxy_proxy_grafana_hostname }};
  40. server_tokens off;
  41. root /dev/null;
  42. {% if matrix_nginx_proxy_https_enabled %}
  43. location /.well-known/acme-challenge {
  44. {% if matrix_nginx_proxy_enabled %}
  45. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  46. resolver {{ matrix_nginx_proxy_http_level_resolver }} valid=5s;
  47. set $backend "matrix-certbot:8080";
  48. proxy_pass http://$backend;
  49. {% else %}
  50. {# Generic configuration for use outside of our container setup #}
  51. proxy_pass http://127.0.0.1:{{ matrix_ssl_lets_encrypt_certbot_standalone_http_port }};
  52. {% endif %}
  53. }
  54. location / {
  55. return 301 https://$http_host$request_uri;
  56. }
  57. {% else %}
  58. {{ render_vhost_directives() }}
  59. {% endif %}
  60. }
  61. {% if matrix_nginx_proxy_https_enabled %}
  62. server {
  63. listen {{ 8443 if matrix_nginx_proxy_enabled else 443 }} ssl http2;
  64. listen [::]:{{ 8443 if matrix_nginx_proxy_enabled else 443 }} ssl http2;
  65. server_name {{ matrix_nginx_proxy_proxy_grafana_hostname }};
  66. server_tokens off;
  67. root /dev/null;
  68. ssl_certificate {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_grafana_hostname }}/fullchain.pem;
  69. ssl_certificate_key {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_grafana_hostname }}/privkey.pem;
  70. ssl_protocols {{ matrix_nginx_proxy_ssl_protocols }};
  71. {% if matrix_nginx_proxy_ssl_ciphers != "" %}
  72. ssl_ciphers {{ matrix_nginx_proxy_ssl_ciphers }};
  73. {% endif %}
  74. ssl_prefer_server_ciphers {{ matrix_nginx_proxy_ssl_prefer_server_ciphers }};
  75. {% if matrix_nginx_proxy_ocsp_stapling_enabled %}
  76. ssl_stapling on;
  77. ssl_stapling_verify on;
  78. ssl_trusted_certificate {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_grafana_hostname }}/chain.pem;
  79. {% endif %}
  80. {% if matrix_nginx_proxy_ssl_session_tickets_off %}
  81. ssl_session_tickets off;
  82. {% endif %}
  83. ssl_session_cache {{ matrix_nginx_proxy_ssl_session_cache }};
  84. ssl_session_timeout {{ matrix_nginx_proxy_ssl_session_timeout }};
  85. {{ render_vhost_directives() }}
  86. }
  87. {% endif %}