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.
 
 

101 lines
3.5 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 {{ matrix_nginx_proxy_http_level_resolver }} 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 {{ matrix_nginx_proxy_x_forwarded_for }};
  30. }
  31. {% endmacro %}
  32. server {
  33. listen {{ 8080 if matrix_nginx_proxy_enabled else 80 }};
  34. listen [::]:{{ 8080 if matrix_nginx_proxy_enabled else 80 }};
  35. server_name {{ matrix_nginx_proxy_proxy_dimension_hostname }};
  36. server_tokens off;
  37. root /dev/null;
  38. {% if matrix_nginx_proxy_https_enabled %}
  39. location /.well-known/acme-challenge {
  40. {% if matrix_nginx_proxy_enabled %}
  41. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  42. resolver {{ matrix_nginx_proxy_http_level_resolver }} valid=5s;
  43. set $backend "matrix-certbot:8080";
  44. proxy_pass http://$backend;
  45. {% else %}
  46. {# Generic configuration for use outside of our container setup #}
  47. proxy_pass http://127.0.0.1:{{ matrix_ssl_lets_encrypt_certbot_standalone_http_port }};
  48. {% endif %}
  49. }
  50. location / {
  51. return 301 https://$http_host$request_uri;
  52. }
  53. {% else %}
  54. {{ render_vhost_directives() }}
  55. {% endif %}
  56. }
  57. {% if matrix_nginx_proxy_https_enabled %}
  58. server {
  59. listen {{ 8443 if matrix_nginx_proxy_enabled else 443 }} ssl http2;
  60. listen [::]:{{ 8443 if matrix_nginx_proxy_enabled else 443 }} ssl http2;
  61. server_name {{ matrix_nginx_proxy_proxy_dimension_hostname }};
  62. server_tokens off;
  63. root /dev/null;
  64. ssl_certificate {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_dimension_hostname }}/fullchain.pem;
  65. ssl_certificate_key {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_dimension_hostname }}/privkey.pem;
  66. ssl_protocols {{ matrix_nginx_proxy_ssl_protocols }};
  67. {% if matrix_nginx_proxy_ssl_ciphers != '' %}
  68. ssl_ciphers {{ matrix_nginx_proxy_ssl_ciphers }};
  69. {% endif %}
  70. ssl_prefer_server_ciphers {{ matrix_nginx_proxy_ssl_prefer_server_ciphers }};
  71. {% if matrix_nginx_proxy_ocsp_stapling_enabled %}
  72. ssl_stapling on;
  73. ssl_stapling_verify on;
  74. ssl_trusted_certificate {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_dimension_hostname }}/chain.pem;
  75. {% endif %}
  76. {% if matrix_nginx_proxy_ssl_session_tickets_off %}
  77. ssl_session_tickets off;
  78. {% endif %}
  79. ssl_session_cache {{ matrix_nginx_proxy_ssl_session_cache }};
  80. ssl_session_timeout {{ matrix_nginx_proxy_ssl_session_timeout }};
  81. {{ render_vhost_directives() }}
  82. }
  83. {% endif %}