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.
 
 

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