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.
 
 

246 line
21 KiB

  1. ---
  2. # matrix-synapse-reverse-proxy companion is a role which brings up a containerized nginx webserver which helps with reverse-proxying to Synapse.
  3. #
  4. # When Synapse is NOT running in worker-mode, reverse-proxying is relatively simple (everything goes to `matrix-synapse:XXXX`).
  5. #
  6. # When Synapse workers are enabled, however, the reverse-proxying configuration is much more complicated.
  7. # Certain requests need to go to certain workers, etc.
  8. # In the past, the main reverse proxy (`matrix-synapse-reverse-proxy-companion`) was handling request routing to the appropriate workers,
  9. # but that only worked well for external requests (from outside of the Matrix server itself).
  10. #
  11. # Without the help of `matrix-synapse-reverse-proxy-companion`, internal services (like Dimension) that would like to talk to Synapse over the container network
  12. # did not have an endpoint for Synapse that they could be pointed to and have it just work.
  13. # If `matrix-synapse-reverse-proxy-companion` was enabled, Dimension could be pointed to its vhost handling Synapse and routing to the appropriate workers,
  14. # but when `matrix-synapse-reverse-proxy-companion` was disabled, this helpful functionality was not available and the best we could do
  15. # is point Dimension to the main Synapse process at `matrix-synapse:XXXX` itself.
  16. # Doing that breaks requests that need to go to specific workers.
  17. # See: https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/2090
  18. #
  19. # What this role does is, it extracts all the Synapse request routing out of the `matrix-synapse-reverse-proxy-companion` role here,
  20. # and makes the `matrix-synapse-reverse-proxy-companion` container service represent Synapse and route appropriately,
  21. # regardless of whether workers are enabled or disabled.
  22. # All other playbook services can then forget about `matrix-synapse` or `matrix-synapse-whatever-worker`, etc.,
  23. # and just use `matrix-synapse-reverse-proxy-companion` as their request destination.
  24. matrix_synapse_reverse_proxy_companion_enabled: true
  25. # renovate: datasource=docker depName=nginx
  26. matrix_synapse_reverse_proxy_companion_version: 1.25.3-alpine
  27. matrix_synapse_reverse_proxy_companion_base_path: "{{ matrix_synapse_base_path }}/reverse-proxy-companion"
  28. matrix_synapse_reverse_proxy_companion_confd_path: "{{ matrix_synapse_reverse_proxy_companion_base_path }}/conf.d"
  29. # List of systemd services that matrix-synapse-reverse-proxy-companion.service depends on
  30. matrix_synapse_reverse_proxy_companion_systemd_required_services_list: "{{ matrix_synapse_reverse_proxy_companion_systemd_required_services_list_default + matrix_synapse_reverse_proxy_companion_systemd_required_services_list_auto + matrix_synapse_reverse_proxy_companion_systemd_required_services_list_custom }}"
  31. matrix_synapse_reverse_proxy_companion_systemd_required_services_list_default: ['docker.service']
  32. matrix_synapse_reverse_proxy_companion_systemd_required_services_list_auto: []
  33. matrix_synapse_reverse_proxy_companion_systemd_required_services_list_custom: []
  34. # List of systemd services that matrix-synapse-reverse-proxy-companion.service wants
  35. matrix_synapse_reverse_proxy_companion_systemd_wanted_services_list: ['matrix-synapse.service']
  36. # We use an official nginx image, which we fix-up to run unprivileged.
  37. # An alternative would be an `nginxinc/nginx-unprivileged` image, but
  38. # that is frequently out of date.
  39. matrix_synapse_reverse_proxy_companion_container_image: "{{ matrix_container_global_registry_prefix }}nginx:{{ matrix_synapse_reverse_proxy_companion_version }}"
  40. matrix_synapse_reverse_proxy_companion_container_image_force_pull: "{{ matrix_synapse_reverse_proxy_companion_container_image.endswith(':latest') }}"
  41. matrix_synapse_reverse_proxy_companion_container_network: ""
  42. # A list of additional container networks that matrix-synapse-reverse-proxy-companion would be connected to.
  43. # The playbook does not create these networks, so make sure they already exist.
  44. matrix_synapse_reverse_proxy_companion_container_additional_networks: []
  45. # Controls whether the matrix-synapse-reverse-proxy-companion container exposes its HTTP Client-Server API port (tcp/8008 in the container).
  46. #
  47. # Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8008"), or empty string to not expose.
  48. matrix_synapse_reverse_proxy_companion_container_client_api_host_bind_port: ''
  49. # Controls whether the matrix-synapse-reverse-proxy-companion container exposes its HTTP Federation (Server-Server) API port (tcp/8048 in the container).
  50. #
  51. # Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8048"), or empty string to not expose.
  52. matrix_synapse_reverse_proxy_companion_container_federation_api_host_bind_port: ''
  53. # matrix_synapse_reverse_proxy_companion_container_labels_traefik_enabled controls whether labels to assist a Traefik reverse-proxy will be attached to the container.
  54. # See `../templates/labels.j2` for details.
  55. #
  56. # To inject your own other container labels, see `matrix_synapse_reverse_proxy_companion_container_labels_additional_labels`.
  57. matrix_synapse_reverse_proxy_companion_container_labels_traefik_enabled: true
  58. matrix_synapse_reverse_proxy_companion_container_labels_traefik_docker_network: "{{ matrix_synapse_reverse_proxy_companion_container_network }}"
  59. matrix_synapse_reverse_proxy_companion_container_labels_traefik_entrypoints: web-secure
  60. matrix_synapse_reverse_proxy_companion_container_labels_traefik_tls_certResolver: default
  61. matrix_synapse_reverse_proxy_companion_container_labels_traefik_hostname: ''
  62. # Controls whether labels will be added for handling the root (/) path
  63. matrix_synapse_reverse_proxy_companion_container_labels_client_root_enabled: true
  64. matrix_synapse_reverse_proxy_companion_container_labels_client_root_traefik_hostname: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_hostname }}"
  65. matrix_synapse_reverse_proxy_companion_container_labels_client_root_traefik_rule: "Host(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_root_traefik_hostname }}`) && Path(`/`)"
  66. matrix_synapse_reverse_proxy_companion_container_labels_client_root_traefik_priority: 0
  67. matrix_synapse_reverse_proxy_companion_container_labels_client_root_traefik_entrypoints: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_entrypoints }}"
  68. matrix_synapse_reverse_proxy_companion_container_labels_client_root_traefik_tls: "{{ matrix_synapse_reverse_proxy_companion_container_labels_client_root_traefik_entrypoints != 'web' }}"
  69. matrix_synapse_reverse_proxy_companion_container_labels_client_root_traefik_tls_certResolver: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_tls_certResolver }}" # noqa var-naming
  70. matrix_synapse_reverse_proxy_companion_container_labels_client_root_redirection_enabled: false
  71. matrix_synapse_reverse_proxy_companion_container_labels_client_root_redirection_url: ""
  72. # Controls whether labels will be added that expose the Client-Server API.
  73. matrix_synapse_reverse_proxy_companion_container_labels_client_api_enabled: true
  74. matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_hostname: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_hostname }}"
  75. matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_path_prefix: /_matrix
  76. matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_rule: "Host(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_hostname }}`) && PathPrefix(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_path_prefix }}`)"
  77. matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_priority: 0
  78. matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_entrypoints: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_entrypoints }}"
  79. matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_tls: "{{ matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_entrypoints != 'web' }}"
  80. matrix_synapse_reverse_proxy_companion_container_labels_client_api_traefik_tls_certResolver: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_tls_certResolver }}" # noqa var-naming
  81. # Controls whether labels will be added that expose the /_synapse/client paths
  82. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_enabled: true
  83. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_hostname: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_hostname }}"
  84. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_path_prefix: /_synapse/client
  85. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_rule: "Host(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_hostname }}`) && PathPrefix(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_path_prefix }}`)"
  86. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_priority: 0
  87. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_entrypoints: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_entrypoints }}"
  88. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_tls: "{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_entrypoints != 'web' }}"
  89. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_client_api_traefik_tls_certResolver: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_tls_certResolver }}" # noqa var-naming
  90. # Controls whether labels will be added that expose the /_synapse/oidc paths
  91. # Enable this if you need OpenID Connect authentication support.
  92. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_enabled: false
  93. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_hostname: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_hostname }}"
  94. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_path_prefix: /_synapse/oidc
  95. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_rule: "Host(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_hostname }}`) && PathPrefix(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_path_prefix }}`)"
  96. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_priority: 0
  97. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_entrypoints: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_entrypoints }}"
  98. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_tls: "{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_entrypoints != 'web' }}"
  99. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_oidc_api_traefik_tls_certResolver: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_tls_certResolver }}" # noqa var-naming
  100. # Controls whether labels will be added that expose the /_synapse/admin paths
  101. # Following these recommendations (https://github.com/matrix-org/synapse/blob/master/docs/reverse_proxy.md), by default, we don't.
  102. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_enabled: false
  103. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_hostname: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_hostname }}"
  104. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_path_prefix: /_synapse/admin
  105. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_rule: "Host(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_hostname }}`) && PathPrefix(`{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_path_prefix }}`)"
  106. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_priority: 0
  107. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_entrypoints: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_entrypoints }}"
  108. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_tls: "{{ matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_entrypoints != 'web' }}"
  109. matrix_synapse_reverse_proxy_companion_container_labels_client_synapse_admin_api_traefik_tls_certResolver: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_tls_certResolver }}" # noqa var-naming
  110. # Controls whether labels will be added that expose the Server-Server API (Federation API).
  111. matrix_synapse_reverse_proxy_companion_container_labels_federation_api_enabled: "{{ matrix_synapse_reverse_proxy_companion_federation_api_enabled }}"
  112. matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_hostname: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_hostname }}"
  113. matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_path_prefix: /_matrix
  114. matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_rule: "Host(`{{ matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_hostname }}`) && PathPrefix(`{{ matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_path_prefix }}`)"
  115. matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_priority: 0
  116. matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_entrypoints: ''
  117. matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_tls: "{{ matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_entrypoints != 'web' }}"
  118. matrix_synapse_reverse_proxy_companion_container_labels_federation_api_traefik_tls_certResolver: "{{ matrix_synapse_reverse_proxy_companion_container_labels_traefik_tls_certResolver }}" # noqa var-naming
  119. # matrix_synapse_reverse_proxy_companion_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file.
  120. # See `../templates/labels.j2` for details.
  121. #
  122. # Example:
  123. # matrix_synapse_reverse_proxy_companion_container_labels_additional_labels: |
  124. # my.label=1
  125. # another.label="here"
  126. matrix_synapse_reverse_proxy_companion_container_labels_additional_labels: ''
  127. # The amount of worker processes and connections
  128. # Consider increasing these when you are expecting high amounts of traffic
  129. # http://nginx.org/en/docs/ngx_core_module.html#worker_connections
  130. matrix_synapse_reverse_proxy_companion_worker_processes: auto
  131. matrix_synapse_reverse_proxy_companion_worker_connections: 1024
  132. # Option to disable the access log
  133. matrix_synapse_reverse_proxy_companion_access_log_enabled: true
  134. # The tmpfs at /tmp needs to be large enough to handle multiple concurrent file uploads.
  135. matrix_synapse_reverse_proxy_companion_tmp_directory_size_mb: "{{ (matrix_synapse_reverse_proxy_companion_federation_api_client_max_body_size_mb | int) * 50 }}"
  136. matrix_synapse_reverse_proxy_companion_tmp_cache_directory_size_mb: "{{ (matrix_synapse_reverse_proxy_companion_synapse_cache_max_size_mb | int) * 2 }}"
  137. # A list of strings containing additional configuration blocks to add to the nginx server configuration (nginx.conf).
  138. # for big matrixservers to enlarge the number of open files to prevent timeouts
  139. # matrix_synapse_reverse_proxy_companion_additional_configuration_blocks:
  140. # - 'worker_rlimit_nofile 30000;'
  141. matrix_synapse_reverse_proxy_companion_additional_configuration_blocks: []
  142. # A list of strings containing additional configuration blocks to add to the nginx event server configuration (nginx.conf).
  143. matrix_synapse_reverse_proxy_companion_event_additional_configuration_blocks: []
  144. # A list of strings containing additional configuration blocks to add to the nginx http's server configuration (nginx-http.conf).
  145. matrix_synapse_reverse_proxy_companion_http_additional_server_configuration_blocks: []
  146. # To increase request timeout in NGINX using proxy_read_timeout, proxy_connect_timeout, proxy_send_timeout, send_timeout directives
  147. # Nginx Default: proxy_connect_timeout 60s; #Defines a timeout for establishing a connection with a proxied server
  148. # Nginx Default: proxy_send_timeout 60s; #Sets a timeout for transmitting a request to the proxied server.
  149. # Nginx Default: proxy_read_timeout 60s; #Defines a timeout for reading a response from the proxied server.
  150. # Nginx Default: send_timeout 60s; #Sets a timeout for transmitting a response to the client.
  151. #
  152. # For more information visit:
  153. # http://nginx.org/en/docs/http/ngx_http_proxy_module.html
  154. # http://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout
  155. # https://www.nginx.com/resources/wiki/start/topics/examples/fullexample2/
  156. #
  157. # Here we are sticking with nginx default values change this value carefully.
  158. matrix_synapse_reverse_proxy_companion_proxy_connect_timeout: 60
  159. matrix_synapse_reverse_proxy_companion_proxy_send_timeout: 60
  160. matrix_synapse_reverse_proxy_companion_proxy_read_timeout: 60
  161. matrix_synapse_reverse_proxy_companion_send_timeout: 60
  162. # For OCSP purposes, we need to define a resolver at the `server{}` level or `http{}` level (we do the latter).
  163. #
  164. # Otherwise, we get warnings like this:
  165. # > [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"
  166. #
  167. # We point it to the internal Docker resolver, which likely delegates to nameservers defined in `/etc/resolv.conf`.
  168. matrix_synapse_reverse_proxy_companion_http_level_resolver: 127.0.0.11
  169. matrix_synapse_reverse_proxy_companion_hostname: "matrix-synapse-reverse-proxy-companion"
  170. # matrix_synapse_reverse_proxy_companion_client_api_addr specifies the address where the Client-Server API is
  171. matrix_synapse_reverse_proxy_companion_client_api_addr: 'matrix-synapse:{{ matrix_synapse_container_client_api_port }}'
  172. # This needs to be equal or higher than the maximum upload size accepted by Synapse.
  173. matrix_synapse_reverse_proxy_companion_client_api_client_max_body_size_mb: 50
  174. # matrix_synapse_reverse_proxy_companion_federation_api_enabled specifies whether reverse proxying for the Federation (Server-Server) API should be done
  175. matrix_synapse_reverse_proxy_companion_federation_api_enabled: true
  176. # matrix_synapse_reverse_proxy_companion_federation_api_addr specifies the address where the Federation (Server-Server) API is
  177. matrix_synapse_reverse_proxy_companion_federation_api_addr: 'matrix-synapse:{{ matrix_synapse_container_federation_api_plain_port }}'
  178. matrix_synapse_reverse_proxy_companion_federation_api_client_max_body_size_mb: "{{ (matrix_synapse_reverse_proxy_companion_client_api_client_max_body_size_mb | int) * 3 }}"
  179. # A list of strings containing additional configuration blocks to add to the nginx vhost handling the Synapse Client-Server API
  180. matrix_synapse_reverse_proxy_companion_synapse_client_api_additional_server_configuration_blocks: []
  181. # A list of strings containing additional configuration blocks to add to the nginx vhost handling the Synapse Federation (Server-Server) API
  182. matrix_synapse_reverse_proxy_companion_synapse_federation_api_additional_server_configuration_blocks: []
  183. # synapse worker activation and endpoint mappings
  184. matrix_synapse_reverse_proxy_companion_synapse_workers_enabled: false
  185. matrix_synapse_reverse_proxy_companion_synapse_workers_list: []
  186. matrix_synapse_reverse_proxy_companion_synapse_generic_worker_client_server_locations: []
  187. matrix_synapse_reverse_proxy_companion_synapse_generic_worker_federation_locations: []
  188. matrix_synapse_reverse_proxy_companion_synapse_stream_writer_typing_stream_worker_client_server_locations: []
  189. matrix_synapse_reverse_proxy_companion_synapse_stream_writer_to_device_stream_worker_client_server_locations: []
  190. matrix_synapse_reverse_proxy_companion_synapse_stream_writer_account_data_stream_worker_client_server_locations: []
  191. matrix_synapse_reverse_proxy_companion_synapse_stream_writer_receipts_stream_worker_client_server_locations: []
  192. matrix_synapse_reverse_proxy_companion_synapse_stream_writer_presence_stream_worker_client_server_locations: []
  193. matrix_synapse_reverse_proxy_companion_synapse_media_repository_locations: []
  194. matrix_synapse_reverse_proxy_companion_synapse_user_dir_locations: []
  195. # synapse content caching
  196. matrix_synapse_reverse_proxy_companion_synapse_cache_enabled: false
  197. matrix_synapse_reverse_proxy_companion_synapse_cache_path: /tmp/synapse-cache
  198. matrix_synapse_reverse_proxy_companion_synapse_cache_keys_zone_name: "STATIC"
  199. matrix_synapse_reverse_proxy_companion_synapse_cache_keys_zone_size: "10m"
  200. matrix_synapse_reverse_proxy_companion_synapse_cache_inactive_time: "48h"
  201. matrix_synapse_reverse_proxy_companion_synapse_cache_max_size_mb: 1024
  202. matrix_synapse_reverse_proxy_companion_synapse_cache_proxy_cache_valid_time: "24h"
  203. # Controls whether matrix-synapse-reverse-proxy-companion trusts an upstream server's X-Forwarded-Proto header.
  204. # The `matrix-synapse-reverse-proxy-companion` does not terminate SSL and always expects to be fronted by another reverse-proxy server (`matrix-nginx-proxy`, etc.).
  205. # As such, it trusts the protocol scheme forwarded by the upstream proxy.
  206. matrix_synapse_reverse_proxy_companion_trust_forwarded_proto: true
  207. matrix_synapse_reverse_proxy_companion_x_forwarded_proto_value: "{{ '$http_x_forwarded_proto' if matrix_synapse_reverse_proxy_companion_trust_forwarded_proto else '$scheme' }}"