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.
 
 

107 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. add_header X-Content-Type-Options nosniff;
  11. add_header X-XSS-Protection "{{ matrix_nginx_proxy_xss_protection }}";
  12. add_header X-Frame-Options SAMEORIGIN;
  13. add_header Content-Security-Policy "frame-ancestors 'self'";
  14. {% if matrix_nginx_proxy_floc_optout_enabled %}
  15. add_header Permissions-Policy interest-cohort=() always;
  16. {% endif %}
  17. {% for configuration_block in matrix_nginx_proxy_proxy_element_additional_server_configuration_blocks %}
  18. {{- configuration_block }}
  19. {% endfor %}
  20. location / {
  21. {% if matrix_nginx_proxy_enabled %}
  22. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  23. resolver {{ matrix_nginx_proxy_http_level_resolver }} valid=5s;
  24. set $backend "matrix-client-element:8080";
  25. proxy_pass http://$backend;
  26. {% else %}
  27. {# Generic configuration for use outside of our container setup #}
  28. proxy_pass http://127.0.0.1:8765;
  29. {% endif %}
  30. proxy_set_header Host $host;
  31. proxy_set_header X-Forwarded-For {{ matrix_nginx_proxy_x_forwarded_for }};
  32. }
  33. {% endmacro %}
  34. server {
  35. listen {{ 8080 if matrix_nginx_proxy_enabled else 80 }};
  36. listen [::]:{{ 8080 if matrix_nginx_proxy_enabled else 80 }};
  37. server_name {{ matrix_nginx_proxy_proxy_element_hostname }};
  38. server_tokens off;
  39. root /dev/null;
  40. {% if matrix_nginx_proxy_https_enabled %}
  41. location /.well-known/acme-challenge {
  42. {% if matrix_nginx_proxy_enabled %}
  43. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  44. resolver {{ matrix_nginx_proxy_http_level_resolver }} valid=5s;
  45. set $backend "matrix-certbot:8080";
  46. proxy_pass http://$backend;
  47. {% else %}
  48. {# Generic configuration for use outside of our container setup #}
  49. proxy_pass http://127.0.0.1:{{ matrix_ssl_lets_encrypt_certbot_standalone_http_port }};
  50. {% endif %}
  51. }
  52. location / {
  53. return 301 https://$http_host$request_uri;
  54. }
  55. {% else %}
  56. {{ render_vhost_directives() }}
  57. {% endif %}
  58. }
  59. {% if matrix_nginx_proxy_https_enabled %}
  60. server {
  61. listen {{ 8443 if matrix_nginx_proxy_enabled else 443 }} ssl http2;
  62. listen [::]:{{ 8443 if matrix_nginx_proxy_enabled else 443 }} ssl http2;
  63. server_name {{ matrix_nginx_proxy_proxy_element_hostname }};
  64. server_tokens off;
  65. root /dev/null;
  66. ssl_certificate {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_element_hostname }}/fullchain.pem;
  67. ssl_certificate_key {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_element_hostname }}/privkey.pem;
  68. ssl_protocols {{ matrix_nginx_proxy_ssl_protocols }};
  69. {% if matrix_nginx_proxy_ssl_ciphers != "" %}
  70. ssl_ciphers {{ matrix_nginx_proxy_ssl_ciphers }};
  71. {% endif %}
  72. ssl_prefer_server_ciphers {{ matrix_nginx_proxy_ssl_prefer_server_ciphers }};
  73. {% if matrix_nginx_proxy_ocsp_stapling_enabled %}
  74. ssl_stapling on;
  75. ssl_stapling_verify on;
  76. ssl_trusted_certificate {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_element_hostname }}/chain.pem;
  77. {% endif %}
  78. {% if matrix_nginx_proxy_ssl_session_tickets_off %}
  79. ssl_session_tickets off;
  80. {% endif %}
  81. ssl_session_cache {{ matrix_nginx_proxy_ssl_session_cache }};
  82. ssl_session_timeout {{ matrix_nginx_proxy_ssl_session_timeout }};
  83. {{ render_vhost_directives() }}
  84. }
  85. {% endif %}