Matrix Docker Ansible eploy
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 

242 líneas
8.4 KiB

  1. #jinja2: lstrip_blocks: "True"
  2. {% set generic_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'generic_worker')|list %}
  3. {% set media_repository_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'media_repository')|list %}
  4. {% set user_dir_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'user_dir')|list %}
  5. {% set frontend_proxy_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'frontend_proxy')|list %}
  6. {% if matrix_nginx_proxy_synapse_workers_enabled %}
  7. # Round Robin "upstream" pools for workers
  8. {% if generic_workers %}
  9. upstream generic_worker_upstream {
  10. # ensures that requests from the same client will always be passed
  11. # to the same server (except when this server is unavailable)
  12. ip_hash;
  13. {% for worker in generic_workers %}
  14. {% if matrix_nginx_proxy_enabled %}
  15. server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
  16. {% else %}
  17. server "127.0.0.1:{{ worker.port }}";
  18. {% endif %}
  19. {% endfor %}
  20. }
  21. {% endif %}
  22. {% if frontend_proxy_workers %}
  23. upstream frontend_proxy_upstream {
  24. {% for worker in frontend_proxy_workers %}
  25. {% if matrix_nginx_proxy_enabled %}
  26. server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
  27. {% else %}
  28. server "127.0.0.1:{{ worker.port }}";
  29. {% endif %}
  30. {% endfor %}
  31. }
  32. {% endif %}
  33. {% if media_repository_workers %}
  34. upstream media_repository_upstream {
  35. {% for worker in media_repository_workers %}
  36. {% if matrix_nginx_proxy_enabled %}
  37. server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
  38. {% else %}
  39. server "127.0.0.1:{{ worker.port }}";
  40. {% endif %}
  41. {% endfor %}
  42. }
  43. {% endif %}
  44. {% if user_dir_workers %}
  45. upstream user_dir_upstream {
  46. {% for worker in user_dir_workers %}
  47. {% if matrix_nginx_proxy_enabled %}
  48. server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
  49. {% else %}
  50. server "127.0.0.1:{{ worker.port }}";
  51. {% endif %}
  52. {% endfor %}
  53. }
  54. {% endif %}
  55. {% endif %}
  56. server {
  57. listen 12080;
  58. server_name {{ matrix_nginx_proxy_proxy_synapse_hostname }};
  59. server_tokens off;
  60. root /dev/null;
  61. gzip on;
  62. gzip_types text/plain application/json;
  63. {% if matrix_nginx_proxy_synapse_workers_enabled %}
  64. {# Workers redirects BEGIN #}
  65. {% if generic_workers %}
  66. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappgeneric_worker
  67. {% for location in matrix_nginx_proxy_synapse_generic_worker_client_server_locations %}
  68. location ~ {{ location }} {
  69. proxy_pass http://generic_worker_upstream$request_uri;
  70. proxy_set_header Host $host;
  71. proxy_set_header X-Forwarded-For $remote_addr;
  72. }
  73. {% endfor %}
  74. {% endif %}
  75. {% if media_repository_workers %}
  76. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappmedia_repository
  77. {% for location in matrix_nginx_proxy_synapse_media_repository_locations %}
  78. location ~ {{ location }} {
  79. proxy_pass http://media_repository_upstream$request_uri;
  80. proxy_set_header Host $host;
  81. proxy_set_header X-Forwarded-For $remote_addr;
  82. client_body_buffer_size 25M;
  83. client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_client_api_client_max_body_size_mb }}M;
  84. proxy_max_temp_file_size 0;
  85. }
  86. {% endfor %}
  87. {% endif %}
  88. {% if user_dir_workers %}
  89. # FIXME: obsolete if matrix_nginx_proxy_proxy_matrix_user_directory_search_enabled is set
  90. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappuser_dir
  91. {% for location in matrix_nginx_proxy_synapse_user_dir_locations %}
  92. location ~ {{ location }} {
  93. proxy_pass http://user_dir_upstream$request_uri;
  94. proxy_set_header Host $host;
  95. proxy_set_header X-Forwarded-For $remote_addr;
  96. }
  97. {% endfor %}
  98. {% endif %}
  99. {% if frontend_proxy_workers %}
  100. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappfrontend_proxy
  101. {% for location in matrix_nginx_proxy_synapse_frontend_proxy_locations %}
  102. location ~ {{ location }} {
  103. proxy_pass http://frontend_proxy_upstream$request_uri;
  104. proxy_set_header Host $host;
  105. proxy_set_header X-Forwarded-For $remote_addr;
  106. }
  107. {% endfor %}
  108. {% if matrix_nginx_proxy_synapse_presence_disabled %}
  109. # FIXME: keep in sync with synapse workers documentation manually
  110. location ~ ^/_matrix/client/(api/v1|r0|unstable)/presence/[^/]+/status {
  111. proxy_pass http://frontend_proxy_upstream$request_uri;
  112. proxy_set_header Host $host;
  113. proxy_set_header X-Forwarded-For $remote_addr;
  114. }
  115. {% endif %}
  116. {% endif %}
  117. {# Workers redirects END #}
  118. {% endif %}
  119. {% for configuration_block in matrix_nginx_proxy_proxy_synapse_additional_server_configuration_blocks %}
  120. {{- configuration_block }}
  121. {% endfor %}
  122. {% if matrix_nginx_proxy_proxy_synapse_metrics %}
  123. location /_synapse/metrics {
  124. {% if matrix_nginx_proxy_enabled %}
  125. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  126. resolver 127.0.0.11 valid=5s;
  127. set $backend "{{ matrix_nginx_proxy_proxy_synapse_metrics_addr_with_container }}";
  128. proxy_pass http://$backend;
  129. {% else %}
  130. {# Generic configuration for use outside of our container setup #}
  131. proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_metrics_addr_sans_container }};
  132. {% endif %}
  133. proxy_set_header Host $host;
  134. proxy_set_header X-Forwarded-For $remote_addr;
  135. {% if matrix_nginx_proxy_proxy_synapse_metrics_basic_auth_enabled %}
  136. auth_basic "protected";
  137. auth_basic_user_file /nginx-data/matrix-synapse-metrics-htpasswd;
  138. {% endif %}
  139. }
  140. {% endif %}
  141. {# Everything else just goes to the API server ##}
  142. location / {
  143. {% if matrix_nginx_proxy_enabled %}
  144. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  145. resolver 127.0.0.11 valid=5s;
  146. set $backend "{{ matrix_nginx_proxy_proxy_synapse_client_api_addr_with_container }}";
  147. proxy_pass http://$backend;
  148. {% else %}
  149. {# Generic configuration for use outside of our container setup #}
  150. proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_client_api_addr_sans_container }};
  151. {% endif %}
  152. proxy_set_header Host $host;
  153. proxy_set_header X-Forwarded-For $remote_addr;
  154. client_body_buffer_size 25M;
  155. client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_client_api_client_max_body_size_mb }}M;
  156. proxy_max_temp_file_size 0;
  157. }
  158. }
  159. {% if matrix_nginx_proxy_proxy_synapse_federation_api_enabled %}
  160. server {
  161. listen 12088;
  162. server_name {{ matrix_nginx_proxy_proxy_synapse_hostname }};
  163. server_tokens off;
  164. root /dev/null;
  165. gzip on;
  166. gzip_types text/plain application/json;
  167. {% if matrix_nginx_proxy_synapse_workers_enabled %}
  168. {% if generic_workers %}
  169. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappgeneric_worker
  170. {% for location in matrix_nginx_proxy_synapse_generic_worker_federation_locations %}
  171. location ~ {{ location }} {
  172. proxy_pass http://generic_worker_upstream$request_uri;
  173. proxy_set_header Host $host;
  174. proxy_set_header X-Forwarded-For $remote_addr;
  175. }
  176. {% endfor %}
  177. {% endif %}
  178. {% if media_repository_workers %}
  179. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappmedia_repository
  180. {% for location in matrix_nginx_proxy_synapse_media_repository_locations %}
  181. location ~ {{ location }} {
  182. proxy_pass http://media_repository_upstream$request_uri;
  183. proxy_set_header Host $host;
  184. proxy_set_header X-Forwarded-For $remote_addr;
  185. client_body_buffer_size 25M;
  186. client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_federation_api_client_max_body_size_mb }}M;
  187. proxy_max_temp_file_size 0;
  188. }
  189. {% endfor %}
  190. {% endif %}
  191. {% endif %}
  192. location / {
  193. {% if matrix_nginx_proxy_enabled %}
  194. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  195. resolver 127.0.0.11 valid=5s;
  196. set $backend "{{ matrix_nginx_proxy_proxy_synapse_federation_api_addr_with_container }}";
  197. proxy_pass http://$backend;
  198. {% else %}
  199. {# Generic configuration for use outside of our container setup #}
  200. proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_federation_api_addr_sans_container }};
  201. {% endif %}
  202. proxy_set_header Host $host;
  203. proxy_set_header X-Forwarded-For $remote_addr;
  204. client_body_buffer_size 25M;
  205. client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_federation_api_client_max_body_size_mb }}M;
  206. proxy_max_temp_file_size 0;
  207. }
  208. }
  209. {% endif %}