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.

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