2019-05-07 21:23:35 +02:00
|
|
|
#jinja2: lstrip_blocks: "True"
|
2019-08-07 11:53:53 +02:00
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{% set generic_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'generic_worker')|list %}
|
|
|
|
{% set media_repository_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'media_repository')|list %}
|
|
|
|
{% set user_dir_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'user_dir')|list %}
|
|
|
|
{% set frontend_proxy_workers = matrix_nginx_proxy_synapse_workers_list|selectattr('type', 'equalto', 'frontend_proxy')|list %}
|
|
|
|
{% if matrix_nginx_proxy_synapse_workers_enabled %}
|
|
|
|
# Round Robin "upstream" pools for workers
|
2017-07-31 22:07:30 +02:00
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{% if generic_workers %}
|
|
|
|
upstream generic_worker_upstream {
|
|
|
|
# ensures that requests from the same client will always be passed
|
|
|
|
# to the same server (except when this server is unavailable)
|
2021-04-24 10:52:45 +02:00
|
|
|
hash $http_x_forwarded_for;
|
2018-08-17 07:00:38 +02:00
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{% for worker in generic_workers %}
|
2021-02-19 10:36:48 +01:00
|
|
|
{% if matrix_nginx_proxy_enabled %}
|
|
|
|
server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
|
|
|
|
{% else %}
|
|
|
|
server "127.0.0.1:{{ worker.port }}";
|
|
|
|
{% endif %}
|
2021-01-25 08:21:17 +01:00
|
|
|
{% endfor %}
|
2018-09-17 09:51:46 +02:00
|
|
|
}
|
2019-08-07 11:53:53 +02:00
|
|
|
{% endif %}
|
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{% if frontend_proxy_workers %}
|
|
|
|
upstream frontend_proxy_upstream {
|
|
|
|
{% for worker in frontend_proxy_workers %}
|
2021-02-19 10:36:48 +01:00
|
|
|
{% if matrix_nginx_proxy_enabled %}
|
|
|
|
server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
|
|
|
|
{% else %}
|
|
|
|
server "127.0.0.1:{{ worker.port }}";
|
|
|
|
{% endif %}
|
2021-01-25 08:21:17 +01:00
|
|
|
{% endfor %}
|
2018-08-21 12:34:34 +02:00
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{% if media_repository_workers %}
|
|
|
|
upstream media_repository_upstream {
|
|
|
|
{% for worker in media_repository_workers %}
|
2021-02-19 10:36:48 +01:00
|
|
|
{% if matrix_nginx_proxy_enabled %}
|
|
|
|
server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
|
|
|
|
{% else %}
|
|
|
|
server "127.0.0.1:{{ worker.port }}";
|
|
|
|
{% endif %}
|
2021-01-25 08:21:17 +01:00
|
|
|
{% endfor %}
|
2018-08-15 09:23:22 +02:00
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{% if user_dir_workers %}
|
|
|
|
upstream user_dir_upstream {
|
|
|
|
{% for worker in user_dir_workers %}
|
2021-02-19 10:36:48 +01:00
|
|
|
{% if matrix_nginx_proxy_enabled %}
|
|
|
|
server "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.port }}";
|
|
|
|
{% else %}
|
|
|
|
server "127.0.0.1:{{ worker.port }}";
|
|
|
|
{% endif %}
|
2021-01-25 08:21:17 +01:00
|
|
|
{% endfor %}
|
2019-01-17 14:55:23 +01:00
|
|
|
}
|
|
|
|
{% endif %}
|
2021-01-25 08:21:17 +01:00
|
|
|
{% endif %}
|
2019-01-17 14:55:23 +01:00
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
server {
|
|
|
|
listen 12080;
|
|
|
|
server_name {{ matrix_nginx_proxy_proxy_synapse_hostname }};
|
2019-05-08 20:49:51 +02:00
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
server_tokens off;
|
|
|
|
root /dev/null;
|
|
|
|
|
|
|
|
gzip on;
|
|
|
|
gzip_types text/plain application/json;
|
2019-05-08 20:49:51 +02:00
|
|
|
|
2020-08-28 13:53:39 +02:00
|
|
|
{% if matrix_nginx_proxy_synapse_workers_enabled %}
|
2020-12-01 21:55:07 +01:00
|
|
|
{# Workers redirects BEGIN #}
|
2020-08-28 13:53:39 +02:00
|
|
|
|
2020-10-28 07:13:19 +01:00
|
|
|
{% if generic_workers %}
|
|
|
|
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappgeneric_worker
|
2021-01-24 21:18:31 +01:00
|
|
|
{% for location in matrix_nginx_proxy_synapse_generic_worker_client_server_locations %}
|
2020-08-28 13:53:39 +02:00
|
|
|
location ~ {{ location }} {
|
|
|
|
proxy_pass http://generic_worker_upstream$request_uri;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2020-04-11 03:08:59 +02:00
|
|
|
|
2020-08-28 13:53:39 +02:00
|
|
|
{% if media_repository_workers %}
|
2020-10-28 07:13:19 +01:00
|
|
|
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappmedia_repository
|
2020-08-28 13:53:39 +02:00
|
|
|
{% for location in matrix_nginx_proxy_synapse_media_repository_locations %}
|
|
|
|
location ~ {{ location }} {
|
|
|
|
proxy_pass http://media_repository_upstream$request_uri;
|
|
|
|
proxy_set_header Host $host;
|
2020-11-10 21:43:33 +01:00
|
|
|
|
|
|
|
client_body_buffer_size 25M;
|
|
|
|
client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_client_api_client_max_body_size_mb }}M;
|
|
|
|
proxy_max_temp_file_size 0;
|
2020-08-28 13:53:39 +02:00
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2020-04-11 03:08:59 +02:00
|
|
|
|
2020-08-28 13:53:39 +02:00
|
|
|
{% if user_dir_workers %}
|
2020-10-28 07:13:19 +01:00
|
|
|
# FIXME: obsolete if matrix_nginx_proxy_proxy_matrix_user_directory_search_enabled is set
|
|
|
|
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappuser_dir
|
2020-08-28 13:53:39 +02:00
|
|
|
{% for location in matrix_nginx_proxy_synapse_user_dir_locations %}
|
|
|
|
location ~ {{ location }} {
|
|
|
|
proxy_pass http://user_dir_upstream$request_uri;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2020-04-11 03:08:59 +02:00
|
|
|
|
2020-08-28 13:53:39 +02:00
|
|
|
{% if frontend_proxy_workers %}
|
2020-10-28 07:13:19 +01:00
|
|
|
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappfrontend_proxy
|
|
|
|
{% for location in matrix_nginx_proxy_synapse_frontend_proxy_locations %}
|
|
|
|
location ~ {{ location }} {
|
2020-08-28 13:53:39 +02:00
|
|
|
proxy_pass http://frontend_proxy_upstream$request_uri;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
}
|
2020-10-28 07:13:19 +01:00
|
|
|
{% endfor %}
|
|
|
|
{% if matrix_nginx_proxy_synapse_presence_disabled %}
|
|
|
|
# FIXME: keep in sync with synapse workers documentation manually
|
2020-08-28 13:53:39 +02:00
|
|
|
location ~ ^/_matrix/client/(api/v1|r0|unstable)/presence/[^/]+/status {
|
|
|
|
proxy_pass http://frontend_proxy_upstream$request_uri;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2020-12-01 21:55:07 +01:00
|
|
|
{# Workers redirects END #}
|
2020-04-11 03:08:59 +02:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{% for configuration_block in matrix_nginx_proxy_proxy_synapse_additional_server_configuration_blocks %}
|
2019-01-17 12:32:46 +01:00
|
|
|
{{- configuration_block }}
|
|
|
|
{% endfor %}
|
2018-10-21 23:20:37 +02:00
|
|
|
|
2019-01-30 19:31:50 +01:00
|
|
|
{% if matrix_nginx_proxy_proxy_synapse_metrics %}
|
|
|
|
location /_synapse/metrics {
|
|
|
|
{% if matrix_nginx_proxy_enabled %}
|
|
|
|
{# Use the embedded DNS resolver in Docker containers to discover the service #}
|
|
|
|
resolver 127.0.0.11 valid=5s;
|
|
|
|
set $backend "{{ matrix_nginx_proxy_proxy_synapse_metrics_addr_with_container }}";
|
|
|
|
proxy_pass http://$backend;
|
|
|
|
{% else %}
|
|
|
|
{# Generic configuration for use outside of our container setup #}
|
|
|
|
proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_metrics_addr_sans_container }};
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
|
|
{% if matrix_nginx_proxy_proxy_synapse_metrics_basic_auth_enabled %}
|
|
|
|
auth_basic "protected";
|
2019-03-12 21:15:22 +01:00
|
|
|
auth_basic_user_file /nginx-data/matrix-synapse-metrics-htpasswd;
|
2019-01-30 19:31:50 +01:00
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
|
2021-10-04 19:53:38 +02:00
|
|
|
{% if matrix_nginx_proxy_enabled and matrix_nginx_proxy_proxy_synapse_metrics %}
|
2021-10-19 23:14:14 +02:00
|
|
|
{% for worker in matrix_nginx_proxy_proxy_synapse_workers_enabled_list %}
|
2021-10-04 19:53:38 +02:00
|
|
|
{% if worker.metrics_port != 0 %}
|
|
|
|
location /_synapse-worker-{{ worker.type }}-{{ worker.instanceId }}/metrics {
|
|
|
|
resolver 127.0.0.11 valid=5s;
|
|
|
|
set $backend "matrix-synapse-worker-{{ worker.type }}-{{ worker.instanceId }}:{{ worker.metrics_port }}";
|
|
|
|
proxy_pass http://$backend/_synapse/metrics;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
|
|
{% if matrix_nginx_proxy_proxy_synapse_metrics_basic_auth_enabled %}
|
|
|
|
auth_basic "protected";
|
|
|
|
auth_basic_user_file /nginx-data/matrix-synapse-metrics-htpasswd;
|
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
{% endif %}
|
2021-10-24 16:00:42 +02:00
|
|
|
{% endfor %}
|
2021-10-04 19:53:38 +02:00
|
|
|
{% endif %}
|
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{# Everything else just goes to the API server ##}
|
|
|
|
location / {
|
2019-05-29 07:32:06 +02:00
|
|
|
{% if matrix_nginx_proxy_enabled %}
|
|
|
|
{# Use the embedded DNS resolver in Docker containers to discover the service #}
|
|
|
|
resolver 127.0.0.11 valid=5s;
|
2021-01-25 08:21:17 +01:00
|
|
|
set $backend "{{ matrix_nginx_proxy_proxy_synapse_client_api_addr_with_container }}";
|
2019-05-29 07:32:06 +02:00
|
|
|
proxy_pass http://$backend;
|
|
|
|
{% else %}
|
|
|
|
{# Generic configuration for use outside of our container setup #}
|
2021-01-25 08:21:17 +01:00
|
|
|
proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_client_api_addr_sans_container }};
|
2019-05-29 07:32:06 +02:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
|
|
client_body_buffer_size 25M;
|
|
|
|
client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_client_api_client_max_body_size_mb }}M;
|
|
|
|
proxy_max_temp_file_size 0;
|
|
|
|
}
|
2019-12-06 10:53:09 +01:00
|
|
|
}
|
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
{% if matrix_nginx_proxy_proxy_synapse_federation_api_enabled %}
|
2019-12-06 10:53:09 +01:00
|
|
|
server {
|
2021-01-25 08:21:17 +01:00
|
|
|
listen 12088;
|
2019-12-06 10:53:09 +01:00
|
|
|
|
2021-01-25 08:21:17 +01:00
|
|
|
server_name {{ matrix_nginx_proxy_proxy_synapse_hostname }};
|
2019-12-06 10:53:09 +01:00
|
|
|
server_tokens off;
|
|
|
|
|
|
|
|
root /dev/null;
|
|
|
|
|
|
|
|
gzip on;
|
|
|
|
gzip_types text/plain application/json;
|
|
|
|
|
2020-08-28 13:53:39 +02:00
|
|
|
{% if matrix_nginx_proxy_synapse_workers_enabled %}
|
2020-10-28 07:13:19 +01:00
|
|
|
{% if generic_workers %}
|
|
|
|
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappgeneric_worker
|
2021-01-24 21:18:31 +01:00
|
|
|
{% for location in matrix_nginx_proxy_synapse_generic_worker_federation_locations %}
|
2020-08-28 13:53:39 +02:00
|
|
|
location ~ {{ location }} {
|
|
|
|
proxy_pass http://generic_worker_upstream$request_uri;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2020-11-10 20:35:39 +01:00
|
|
|
{% if media_repository_workers %}
|
|
|
|
# https://github.com/matrix-org/synapse/blob/master/docs/workers.md#synapseappmedia_repository
|
|
|
|
{% for location in matrix_nginx_proxy_synapse_media_repository_locations %}
|
|
|
|
location ~ {{ location }} {
|
|
|
|
proxy_pass http://media_repository_upstream$request_uri;
|
|
|
|
proxy_set_header Host $host;
|
2020-11-10 21:43:33 +01:00
|
|
|
|
|
|
|
client_body_buffer_size 25M;
|
|
|
|
client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_federation_api_client_max_body_size_mb }}M;
|
|
|
|
proxy_max_temp_file_size 0;
|
2020-11-10 20:35:39 +01:00
|
|
|
}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2020-08-27 15:25:32 +02:00
|
|
|
{% endif %}
|
2020-04-11 03:08:59 +02:00
|
|
|
|
2019-02-05 10:07:08 +01:00
|
|
|
location / {
|
|
|
|
{% if matrix_nginx_proxy_enabled %}
|
|
|
|
{# Use the embedded DNS resolver in Docker containers to discover the service #}
|
|
|
|
resolver 127.0.0.11 valid=5s;
|
2021-01-25 08:21:17 +01:00
|
|
|
set $backend "{{ matrix_nginx_proxy_proxy_synapse_federation_api_addr_with_container }}";
|
2019-02-05 10:07:08 +01:00
|
|
|
proxy_pass http://$backend;
|
|
|
|
{% else %}
|
|
|
|
{# Generic configuration for use outside of our container setup #}
|
2021-01-25 08:21:17 +01:00
|
|
|
proxy_pass http://{{ matrix_nginx_proxy_proxy_synapse_federation_api_addr_sans_container }};
|
2019-02-05 10:07:08 +01:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
|
|
|
client_body_buffer_size 25M;
|
|
|
|
client_max_body_size {{ matrix_nginx_proxy_proxy_matrix_federation_api_client_max_body_size_mb }}M;
|
|
|
|
proxy_max_temp_file_size 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{% endif %}
|