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