Matrix Docker Ansible eploy
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

232 satır
7.9 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. hash $http_x_forwarded_for;
  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. }
  72. {% endfor %}
  73. {% endif %}
  74. {% if media_repository_workers %}
  75. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappmedia_repository
  76. {% for location in matrix_nginx_proxy_synapse_media_repository_locations %}
  77. location ~ {{ location }} {
  78. proxy_pass http://media_repository_upstream$request_uri;
  79. proxy_set_header Host $host;
  80. client_body_buffer_size 25M;
  81. client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_client_api_client_max_body_size_mb }}M;
  82. proxy_max_temp_file_size 0;
  83. }
  84. {% endfor %}
  85. {% endif %}
  86. {% if user_dir_workers %}
  87. # FIXME: obsolete if matrix_nginx_proxy_proxy_matrix_user_directory_search_enabled is set
  88. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappuser_dir
  89. {% for location in matrix_nginx_proxy_synapse_user_dir_locations %}
  90. location ~ {{ location }} {
  91. proxy_pass http://user_dir_upstream$request_uri;
  92. proxy_set_header Host $host;
  93. }
  94. {% endfor %}
  95. {% endif %}
  96. {% if frontend_proxy_workers %}
  97. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappfrontend_proxy
  98. {% for location in matrix_nginx_proxy_synapse_frontend_proxy_locations %}
  99. location ~ {{ location }} {
  100. proxy_pass http://frontend_proxy_upstream$request_uri;
  101. proxy_set_header Host $host;
  102. }
  103. {% endfor %}
  104. {% if matrix_nginx_proxy_synapse_presence_disabled %}
  105. # FIXME: keep in sync with synapse workers documentation manually
  106. location ~ ^/_matrix/client/(api/v1|r0|unstable)/presence/[^/]+/status {
  107. proxy_pass http://frontend_proxy_upstream$request_uri;
  108. proxy_set_header Host $host;
  109. }
  110. {% endif %}
  111. {% endif %}
  112. {# Workers redirects END #}
  113. {% endif %}
  114. {% for configuration_block in matrix_nginx_proxy_proxy_synapse_additional_server_configuration_blocks %}
  115. {{- configuration_block }}
  116. {% endfor %}
  117. {% if matrix_nginx_proxy_proxy_synapse_metrics %}
  118. location /_synapse/metrics {
  119. {% if matrix_nginx_proxy_enabled %}
  120. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  121. resolver 127.0.0.11 valid=5s;
  122. set $backend "{{ matrix_nginx_proxy_proxy_synapse_metrics_addr_with_container }}";
  123. proxy_pass http://$backend;
  124. {% else %}
  125. {# Generic configuration for use outside of our container setup #}
  126. proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_metrics_addr_sans_container }};
  127. {% endif %}
  128. proxy_set_header Host $host;
  129. {% if matrix_nginx_proxy_proxy_synapse_metrics_basic_auth_enabled %}
  130. auth_basic "protected";
  131. auth_basic_user_file /nginx-data/matrix-synapse-metrics-htpasswd;
  132. {% endif %}
  133. }
  134. {% endif %}
  135. {# Everything else just goes to the API server ##}
  136. location / {
  137. {% if matrix_nginx_proxy_enabled %}
  138. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  139. resolver 127.0.0.11 valid=5s;
  140. set $backend "{{ matrix_nginx_proxy_proxy_synapse_client_api_addr_with_container }}";
  141. proxy_pass http://$backend;
  142. {% else %}
  143. {# Generic configuration for use outside of our container setup #}
  144. proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_client_api_addr_sans_container }};
  145. {% endif %}
  146. proxy_set_header Host $host;
  147. client_body_buffer_size 25M;
  148. client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_client_api_client_max_body_size_mb }}M;
  149. proxy_max_temp_file_size 0;
  150. }
  151. }
  152. {% if matrix_nginx_proxy_proxy_synapse_federation_api_enabled %}
  153. server {
  154. listen 12088;
  155. server_name {{ matrix_nginx_proxy_proxy_synapse_hostname }};
  156. server_tokens off;
  157. root /dev/null;
  158. gzip on;
  159. gzip_types text/plain application/json;
  160. {% if matrix_nginx_proxy_synapse_workers_enabled %}
  161. {% if generic_workers %}
  162. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappgeneric_worker
  163. {% for location in matrix_nginx_proxy_synapse_generic_worker_federation_locations %}
  164. location ~ {{ location }} {
  165. proxy_pass http://generic_worker_upstream$request_uri;
  166. proxy_set_header Host $host;
  167. }
  168. {% endfor %}
  169. {% endif %}
  170. {% if media_repository_workers %}
  171. # https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappmedia_repository
  172. {% for location in matrix_nginx_proxy_synapse_media_repository_locations %}
  173. location ~ {{ location }} {
  174. proxy_pass http://media_repository_upstream$request_uri;
  175. proxy_set_header Host $host;
  176. client_body_buffer_size 25M;
  177. client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_federation_api_client_max_body_size_mb }}M;
  178. proxy_max_temp_file_size 0;
  179. }
  180. {% endfor %}
  181. {% endif %}
  182. {% endif %}
  183. location / {
  184. {% if matrix_nginx_proxy_enabled %}
  185. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  186. resolver 127.0.0.11 valid=5s;
  187. set $backend "{{ matrix_nginx_proxy_proxy_synapse_federation_api_addr_with_container }}";
  188. proxy_pass http://$backend;
  189. {% else %}
  190. {# Generic configuration for use outside of our container setup #}
  191. proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_federation_api_addr_sans_container }};
  192. {% endif %}
  193. proxy_set_header Host $host;
  194. client_body_buffer_size 25M;
  195. client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_federation_api_client_max_body_size_mb }}M;
  196. proxy_max_temp_file_size 0;
  197. }
  198. }
  199. {% endif %}