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.
 
 

109 lines
4.0 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_etherpad_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-etherpad:9001";
  23. proxy_pass http://$backend;
  24. {# These are proxy directives needed specifically by Etherpad #}
  25. proxy_buffering off;
  26. proxy_http_version 1.1; {# recommended with keepalive connections #}
  27. proxy_pass_header Server;
  28. proxy_set_header Host $host;
  29. proxy_set_header X-Forwarded-Proto {{ matrix_nginx_proxy_x_forwarded_proto_value }}; {# for EP to set secure cookie flag when https is used #}
  30. {# WebSocket proxying - from http://nginx.org/en/docs/http/websocket.html #}
  31. proxy_set_header Upgrade $http_upgrade;
  32. proxy_set_header Connection $connection_upgrade;
  33. {% else %}
  34. {# Generic configuration for use outside of our container setup #}
  35. # A good guide for setting up your Etherpad behind nginx:
  36. # https://docs.gandi.net/en/cloud/tutorials/etherpad_lite.html
  37. proxy_pass http://127.0.0.1:9001/;
  38. {% endif %}
  39. }
  40. {% endmacro %}
  41. server {
  42. listen {{ 8080 if matrix_nginx_proxy_enabled else 80 }};
  43. listen [::]:{{ 8080 if matrix_nginx_proxy_enabled else 80 }};
  44. server_name {{ matrix_nginx_proxy_proxy_etherpad_hostname }};
  45. server_tokens off;
  46. root /dev/null;
  47. {% if matrix_nginx_proxy_https_enabled %}
  48. location /.well-known/acme-challenge {
  49. {% if matrix_nginx_proxy_enabled %}
  50. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  51. resolver {{ matrix_nginx_proxy_http_level_resolver }} valid=5s;
  52. set $backend "matrix-certbot:8080";
  53. proxy_pass http://$backend;
  54. {% else %}
  55. {# Generic configuration for use outside of our container setup #}
  56. proxy_pass http://127.0.0.1:{{ matrix_ssl_lets_encrypt_certbot_standalone_http_port }};
  57. {% endif %}
  58. }
  59. location / {
  60. return 301 https://$http_host$request_uri;
  61. }
  62. {% else %}
  63. {{ render_vhost_directives() }}
  64. {% endif %}
  65. }
  66. {% if matrix_nginx_proxy_https_enabled %}
  67. server {
  68. listen {{ 8443 if matrix_nginx_proxy_enabled else 443 }} ssl http2;
  69. listen [::]:{{ 8443 if matrix_nginx_proxy_enabled else 443 }} ssl http2;
  70. server_name {{ matrix_nginx_proxy_proxy_etherpad_hostname }};
  71. server_tokens off;
  72. root /dev/null;
  73. ssl_certificate {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_etherpad_hostname }}/fullchain.pem;
  74. ssl_certificate_key {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_etherpad_hostname }}/privkey.pem;
  75. ssl_protocols {{ matrix_nginx_proxy_ssl_protocols }};
  76. {% if matrix_nginx_proxy_ssl_ciphers != '' %}
  77. ssl_ciphers {{ matrix_nginx_proxy_ssl_ciphers }};
  78. {% endif %}
  79. ssl_prefer_server_ciphers {{ matrix_nginx_proxy_ssl_prefer_server_ciphers }};
  80. {% if matrix_nginx_proxy_ocsp_stapling_enabled %}
  81. ssl_stapling on;
  82. ssl_stapling_verify on;
  83. ssl_trusted_certificate {{ matrix_ssl_config_dir_path }}/live/{{ matrix_nginx_proxy_proxy_etherpad_hostname }}/chain.pem;
  84. {% endif %}
  85. {% if matrix_nginx_proxy_ssl_session_tickets_off %}
  86. ssl_session_tickets off;
  87. {% endif %}
  88. ssl_session_cache {{ matrix_nginx_proxy_ssl_session_cache }};
  89. ssl_session_timeout {{ matrix_nginx_proxy_ssl_session_timeout }};
  90. {{ render_vhost_directives() }}
  91. }
  92. {% endif %}