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.
 
 

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