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.
 
 

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