From ba75ab496d7875f9209b59d32cb8408923b2ddec Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 17 Jan 2019 16:21:04 +0200 Subject: [PATCH] Send Host/X-Forwarded-For to mxisd It worked without it too, but doing this is more consistent with the mxisd recommendations. --- group_vars/matrix-servers | 2 +- roles/matrix-mxisd/defaults/main.yml | 2 +- .../templates/nginx-conf.d/matrix-synapse.conf.j2 | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/group_vars/matrix-servers b/group_vars/matrix-servers index 767b36eb4..3167c6121 100644 --- a/group_vars/matrix-servers +++ b/group_vars/matrix-servers @@ -119,7 +119,7 @@ matrix_mxisd_synapsesql_type: postgresql matrix_mxisd_synapsesql_connection: //{{ matrix_synapse_database_host }}/{{ matrix_synapse_database_database }}?user={{ matrix_synapse_database_user }}&password={{ matrix_synapse_database_password }} matrix_mxisd_dns_overwrite_enabled: true -matrix_mxisd_dns_overwrite_homeserver_client_name: "matrix-mxisd" +matrix_mxisd_dns_overwrite_homeserver_client_name: "{{ hostname_matrix }}" matrix_mxisd_dns_overwrite_homeserver_client_value: "http://{{ 'matrix-corporal:41080' if matrix_corporal_enabled else 'matrix-synapse:8008' }}" # By default, we send mail through the `matrix-mailer` service. diff --git a/roles/matrix-mxisd/defaults/main.yml b/roles/matrix-mxisd/defaults/main.yml index 8970e2df8..a0a1f781b 100644 --- a/roles/matrix-mxisd/defaults/main.yml +++ b/roles/matrix-mxisd/defaults/main.yml @@ -40,7 +40,7 @@ matrix_mxisd_threepid_medium_email_connectors_smtp_password: "" # Useful when reverse-proxying certain URLs (e.g. `/_matrix/client/r0/user_directory/search`) to mxisd, # so that mxisd can rewrite the original URL to one that would reach the homeserver. matrix_mxisd_dns_overwrite_enabled: false -matrix_mxisd_dns_overwrite_homeserver_client_name: "matrix-mxisd" +matrix_mxisd_dns_overwrite_homeserver_client_name: "{{ hostname_matrix }}" matrix_mxisd_dns_overwrite_homeserver_client_value: "http://matrix-synapse:8008" # Default mxisd configuration template which covers the generic use case. diff --git a/roles/matrix-nginx-proxy/templates/nginx-conf.d/matrix-synapse.conf.j2 b/roles/matrix-nginx-proxy/templates/nginx-conf.d/matrix-synapse.conf.j2 index 34c9d0ab5..a88bf27e7 100644 --- a/roles/matrix-nginx-proxy/templates/nginx-conf.d/matrix-synapse.conf.j2 +++ b/roles/matrix-nginx-proxy/templates/nginx-conf.d/matrix-synapse.conf.j2 @@ -71,6 +71,9 @@ server { {# Generic configuration for use outside of our container setup #} proxy_pass http://{{ matrix_nginx_proxy_proxy_matrix_identity_api_addr_sans_container }}; {% endif %} + + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; } {% endif %} @@ -85,6 +88,9 @@ server { {# Generic configuration for use outside of our container setup #} proxy_pass http://{{ matrix_nginx_proxy_proxy_matrix_user_directory_search_addr_sans_container }}; {% endif %} + + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $remote_addr; } {% endif %}