Matrix Docker Ansible eploy
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

186 lignes
11 KiB

  1. ---
  2. # matrix-homeserver-proxy is a role which brings up a containerized nginx webserver which helps with reverse-proxying to the Matrix homeserver (Synapse, etc.).
  3. #
  4. # Certain services (like matrix-media-repo, matrix-corporal, identity servers, etc.) may need to capture some requests destined for the homeserver
  5. # and handle them instead of it.
  6. #
  7. # This role helps other services (bots, bridges, etc.) reach the homeserver in a way that:
  8. # - is not very direct, so as to allow for some routes (media repo, etc.) to actually go elsewhere
  9. # - is not via the public network and/or via HTTPS, which introduces major performance penalties
  10. #
  11. # Performance-wise, benchmarks show that:
  12. # - each local (container) nginx hop adds about a 200 rps penalty
  13. # - SSL termination (on the Traefik side) adds a 350 rps penalty
  14. # - going over the public network adds another 70 rps penalty
  15. #
  16. # It's something like this for an existing flow (which will be gone soon):
  17. # 1. public network, Traefik + SSL: 70 rps
  18. # 2. `matrix-nginx-proxy:8008`: 600 rps
  19. # 3. `matrix-nginx-proxy:12080` 850 rps
  20. # 4. `matrix-synapse-reverse-proxy-companion:8008`: 1000 rps
  21. # 5. `matrix-synapse:8008`: 1200 rps
  22. #
  23. # Traefik was additionally benchmarked to see where the slowness comes from. Results are like this:
  24. # 1. public network, Traefik + SSL: 70 rps
  25. # 2. local (container) network, Traefik + SSL: 150 rps
  26. # 3. local (container) network, Traefik without SSL: 500 rps
  27. # 4. `matrix-nginx-proxy:8008`: 600 rps
  28. #
  29. # It's obvious that minimizing the number of hops helps a lot and that not using SSL and/or the public network is important.
  30. matrix_homeserver_proxy_enabled: true
  31. matrix_homeserver_proxy_identifier: matrix-homeserver-proxy
  32. # renovate: datasource=docker depName=nginx
  33. matrix_homeserver_proxy_version: 1.25.3-alpine
  34. matrix_homeserver_proxy_base_path: "{{ matrix_base_data_path }}/homeserver-proxy"
  35. matrix_homeserver_proxy_confd_path: "{{ matrix_homeserver_proxy_base_path }}/conf.d"
  36. # List of systemd services that matrix-homeserver-proxy.service depends on
  37. matrix_homeserver_proxy_systemd_required_services_list: ['docker.service']
  38. # List of systemd services that matrix-homeserver-proxy.service wants
  39. matrix_homeserver_proxy_systemd_wanted_services_list: "{{ matrix_homeserver_proxy_systemd_wanted_services_list_auto + matrix_homeserver_proxy_systemd_wanted_services_list_custom }}"
  40. matrix_homeserver_proxy_systemd_wanted_services_list_auto: []
  41. matrix_homeserver_proxy_systemd_wanted_services_list_custom: []
  42. # We use an official nginx image, which we fix-up to run unprivileged.
  43. # An alternative would be an `nginxinc/nginx-unprivileged` image, but that is frequently out of date.
  44. matrix_homeserver_proxy_container_image: "{{ matrix_container_global_registry_prefix }}nginx:{{ matrix_homeserver_proxy_version }}"
  45. matrix_homeserver_proxy_container_image_force_pull: "{{ matrix_homeserver_proxy_container_image.endswith(':latest') }}"
  46. matrix_homeserver_proxy_container_network: matrix-homeserver-proxy
  47. # A list of additional container networks that matrix-homeserver-proxy would be connected to.
  48. # The playbook does not create these networks, so make sure they already exist.
  49. matrix_homeserver_proxy_container_additional_networks: []
  50. # Controls whether the matrix-homeserver-proxy container exposes its HTTP Client-Server API port (tcp/8008 in the container).
  51. #
  52. # Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8008"), or empty string to not expose.
  53. matrix_homeserver_proxy_container_client_api_host_bind_port: ''
  54. # Controls whether the matrix-homeserver-proxy container exposes its HTTP Federation (Server-Server) API port (tcp/8048 in the container).
  55. #
  56. # Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8048"), or empty string to not expose.
  57. matrix_homeserver_proxy_container_federation_api_host_bind_port: ''
  58. # Option to disable the access log
  59. matrix_homeserver_proxy_access_log_enabled: true
  60. # Controls whether to send access logs to a remote syslog-compatible server
  61. matrix_homeserver_proxy_access_log_syslog_integration_enabled: false
  62. matrix_homeserver_proxy_access_log_syslog_integration_server_port: ''
  63. # This is intentionally different. The maximum allowed length is 32 characters and dashes are not allowed.
  64. matrix_homeserver_proxy_access_log_syslog_integration_tag: matrix_homeserver_proxy
  65. # The tmpfs at /tmp needs to be large enough to handle multiple concurrent file uploads.
  66. matrix_homeserver_proxy_tmp_directory_size_mb: "{{ (matrix_homeserver_proxy_federation_api_client_max_body_size_mb | int) * 50 }}"
  67. matrix_homeserver_proxy_tmp_cache_directory_size_mb: "{{ (matrix_homeserver_proxy_cache_max_size_mb | int) * 2 }}"
  68. # A list of strings containing additional configuration blocks to add to the nginx server configuration (nginx.conf).
  69. # for big matrixservers to enlarge the number of open files to prevent timeouts
  70. # matrix_homeserver_proxy_additional_configuration_blocks:
  71. # - 'worker_rlimit_nofile 30000;'
  72. matrix_homeserver_proxy_additional_configuration_blocks: []
  73. # A list of strings containing additional configuration blocks to add to the nginx event server configuration (nginx.conf).
  74. matrix_homeserver_proxy_event_additional_configuration_blocks: []
  75. # A list of strings containing additional configuration blocks to add to the nginx http's server configuration (nginx-http.conf).
  76. matrix_homeserver_proxy_http_additional_server_configuration_blocks: []
  77. # To increase request timeout in NGINX using proxy_read_timeout, proxy_connect_timeout, proxy_send_timeout, send_timeout directives
  78. # Nginx Default: proxy_connect_timeout 60s; #Defines a timeout for establishing a connection with a proxied server
  79. # Nginx Default: proxy_send_timeout 60s; #Sets a timeout for transmitting a request to the proxied server.
  80. # Nginx Default: proxy_read_timeout 60s; #Defines a timeout for reading a response from the proxied server.
  81. # Nginx Default: send_timeout 60s; #Sets a timeout for transmitting a response to the client.
  82. #
  83. # For more information visit:
  84. # http://nginx.org/en/docs/http/ngx_http_proxy_module.html
  85. # http://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout
  86. # https://www.nginx.com/resources/wiki/start/topics/examples/fullexample2/
  87. #
  88. # Here we are sticking with nginx default values change this value carefully.
  89. matrix_homeserver_proxy_proxy_connect_timeout: 60
  90. matrix_homeserver_proxy_proxy_send_timeout: 60
  91. matrix_homeserver_proxy_proxy_read_timeout: 60
  92. matrix_homeserver_proxy_send_timeout: 60
  93. # For OCSP purposes, we need to define a resolver at the `server{}` level or `http{}` level (we do the latter).
  94. #
  95. # Otherwise, we get warnings like this:
  96. # > [warn] 22#22: no resolver defined to resolve r3.o.lencr.org while requesting certificate status, responder: r3.o.lencr.org, certificate: "/matrix/ssl/config/live/.../fullchain.pem"
  97. #
  98. # We point it to the internal Docker resolver, which likely delegates to nameservers defined in `/etc/resolv.conf`.
  99. matrix_homeserver_proxy_http_level_resolver: 127.0.0.11
  100. matrix_homeserver_proxy_hostname: "{{ matrix_homeserver_proxy_identifier }}"
  101. # matrix_homeserver_proxy_client_api_addr specifies the address where the Client-Server API is
  102. matrix_homeserver_proxy_client_api_addr: ''
  103. # This needs to be equal or higher than the maximum upload size accepted by the homeserver.
  104. matrix_homeserver_proxy_client_api_client_max_body_size_mb: 50
  105. # Tells whether `/_synapse/client` is forwarded to the Matrix Client API server.
  106. matrix_homeserver_proxy_client_api_forwarded_location_synapse_client_api_enabled: true
  107. # Tells whether `/_synapse/oidc` is forwarded to the Matrix Client API server.
  108. # Enable this if you need OpenID Connect authentication support.
  109. matrix_homeserver_proxy_client_api_forwarded_location_synapse_oidc_api_enabled: false
  110. # Tells whether `/_synapse/admin` is forwarded to the Matrix Client API server.
  111. # Following these recommendations (https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.md), by default, we don't.
  112. matrix_homeserver_proxy_client_api_forwarded_location_synapse_admin_api_enabled: false
  113. # `matrix_homeserver_proxy_client_api_forwarded_location_prefix_regexes` holds
  114. # the location prefixes that get forwarded to the Matrix Client API server.
  115. # These locations get combined into a regex like this `^(/_matrix|/_synapse/client)`.
  116. matrix_homeserver_proxy_client_api_forwarded_location_prefix_regexes: |
  117. {{
  118. (['/_matrix'])
  119. +
  120. (['/_synapse/client'] if matrix_homeserver_proxy_client_api_forwarded_location_synapse_client_api_enabled else [])
  121. +
  122. (['/_synapse/oidc'] if matrix_homeserver_proxy_client_api_forwarded_location_synapse_oidc_api_enabled else [])
  123. +
  124. (['/_synapse/admin'] if matrix_homeserver_proxy_client_api_forwarded_location_synapse_admin_api_enabled else [])
  125. }}
  126. # Specifies where requests for the root URI (`/`) on the `matrix.` domain should be redirected.
  127. # If this has an empty value, they're just passed to the homeserver, which serves a static page.
  128. # If you'd like to make `https://matrix.DOMAIN` redirect to `https://element.DOMAIN` (or something of that sort), specify the domain name here.
  129. # Example value: `element.DOMAIN` (or `{{ matrix_server_fqn_element }}`).
  130. matrix_homeserver_proxy_client_redirect_root_uri_to_domain: ""
  131. # A list of strings containing additional configuration blocks to add to the nginx vhost handling the Client-Server API
  132. matrix_homeserver_proxy_client_api_additional_server_configuration_blocks: "{{ matrix_homeserver_proxy_client_api_additional_server_configuration_blocks_auto + matrix_homeserver_proxy_client_api_additional_server_configuration_blocks_custom }}"
  133. matrix_homeserver_proxy_client_api_additional_server_configuration_blocks_auto: []
  134. matrix_homeserver_proxy_client_api_additional_server_configuration_blocks_custom: []
  135. # matrix_homeserver_proxy_federation_api_enabled specifies whether reverse proxying for the Federation (Server-Server) API should be done
  136. matrix_homeserver_proxy_federation_api_enabled: true
  137. # matrix_homeserver_proxy_federation_api_addr specifies the address where the Federation (Server-Server) API is
  138. matrix_homeserver_proxy_federation_api_addr: ''
  139. matrix_homeserver_proxy_federation_api_client_max_body_size_mb: "{{ (matrix_homeserver_proxy_client_api_client_max_body_size_mb | int) * 3 }}"
  140. # A list of strings containing additional configuration blocks to add to the nginx vhost handling the Federation (Server-Server) API
  141. matrix_homeserver_proxy_federation_api_additional_server_configuration_blocks: "{{ matrix_homeserver_proxy_federation_api_additional_server_configuration_blocks_auto + matrix_homeserver_proxy_federation_api_additional_server_configuration_blocks_custom }}"
  142. matrix_homeserver_proxy_federation_api_additional_server_configuration_blocks_auto: []
  143. matrix_homeserver_proxy_federation_api_additional_server_configuration_blocks_custom: []
  144. # Controls whether matrix-homeserver-proxy trusts an upstream server's X-Forwarded-Proto header.
  145. # The `matrix-homeserver-proxy` does not terminate SSL and always expects to be fronted by another reverse-proxy server.
  146. # As such, it trusts the protocol scheme forwarded by the upstream proxy.
  147. matrix_homeserver_proxy_trust_forwarded_proto: true
  148. matrix_homeserver_proxy_x_forwarded_proto_value: "{{ '$http_x_forwarded_proto' if matrix_homeserver_proxy_trust_forwarded_proto else '$scheme' }}"
  149. # The amount of worker processes and connections
  150. # Consider increasing these when you are expecting high amounts of traffic
  151. # http://nginx.org/en/docs/ngx_core_module.html#worker_connections
  152. matrix_homeserver_proxy_worker_processes: auto
  153. matrix_homeserver_proxy_worker_connections: 1024