diff --git a/ansible/playbook/runa.yml b/ansible/playbook/runa.yml index 55466cc..ae3dd2d 100644 --- a/ansible/playbook/runa.yml +++ b/ansible/playbook/runa.yml @@ -29,7 +29,7 @@ include_role: name: elementweb tags: - - docker + - elementweb when: matrix_service == "elementweb" - name: Add synapse include_role: diff --git a/ansible/roles/elementweb/tasks/main.yml b/ansible/roles/elementweb/tasks/main.yml index dfd5061..e04c0f3 100644 --- a/ansible/roles/elementweb/tasks/main.yml +++ b/ansible/roles/elementweb/tasks/main.yml @@ -18,16 +18,6 @@ - dir - test -- name: Create nginx log dir - ansible.builtin.file: - path: /home/{{ ansible_user }}/docker_compose/{{ matrix_service }}/nginx - state: directory - owner: "{{ ansible_user }}" - mode: '0755' - tags: - - dir - - test - - name: Create nginx config ansible.builtin.template: src: "nginx/elementweb.conf" diff --git a/ansible/roles/synapse/files/basedir/config/synapse-worker-federation.yaml b/ansible/roles/synapse/files/basedir/config/synapse-worker-federation.yaml index 5c1b677..3c3bf8f 100755 --- a/ansible/roles/synapse/files/basedir/config/synapse-worker-federation.yaml +++ b/ansible/roles/synapse/files/basedir/config/synapse-worker-federation.yaml @@ -9,3 +9,10 @@ worker_listeners: - names: - client - federation + - port: 9000 + type: metrics + tls: false + x_forwarded: true + resources: + - names: [metrics] + compress: false diff --git a/ansible/roles/synapse/files/basedir/config/synapse-worker-sync.yaml b/ansible/roles/synapse/files/basedir/config/synapse-worker-sync.yaml index 21d3596..8756dab 100755 --- a/ansible/roles/synapse/files/basedir/config/synapse-worker-sync.yaml +++ b/ansible/roles/synapse/files/basedir/config/synapse-worker-sync.yaml @@ -9,3 +9,10 @@ worker_listeners: - names: - client - federation + - port: 9000 + type: metrics + tls: false + x_forwarded: true + resources: + - names: [metrics] + compress: false diff --git a/ansible/roles/synapse/files/basedir/docker-compose.yaml b/ansible/roles/synapse/files/basedir/docker-compose.yaml index 87d2003..967511b 100644 --- a/ansible/roles/synapse/files/basedir/docker-compose.yaml +++ b/ansible/roles/synapse/files/basedir/docker-compose.yaml @@ -9,6 +9,7 @@ services: - run - --config-path=/config/homeserver.yaml restart: always + container_name: synapse-main synapse-worker-generic: image: matrixdotorg/synapse:${SYNAPSE_VERSION} @@ -24,6 +25,7 @@ services: depends_on: - synapse-main restart: unless-stopped + container_name: synapse-worker-generic synapse-worker-sync: image: matrixdotorg/synapse:${SYNAPSE_VERSION} @@ -39,6 +41,7 @@ services: depends_on: - synapse-main restart: unless-stopped + container_name: synapse-worker-sync synapse-worker-federation: image: matrixdotorg/synapse:${SYNAPSE_VERSION} @@ -54,6 +57,7 @@ services: depends_on: - synapse-main restart: unless-stopped + container_name: synapse-worker-federation nginx: @@ -66,9 +70,11 @@ services: - /ssl:/ssl - /mnt/logs/nginx:/var/log/nginx/ restart: unless-stopped + container_name: nginx redis: image: "redis:latest" ports: - "6379:6379/tcp" restart: "unless-stopped" + container_name: redis diff --git a/ansible/roles/synapse/tasks/main.yml b/ansible/roles/synapse/tasks/main.yml index b0ab0bd..46ed388 100644 --- a/ansible/roles/synapse/tasks/main.yml +++ b/ansible/roles/synapse/tasks/main.yml @@ -6,4 +6,22 @@ mode: '0644' tags: - files - - test +- name: Create nginx dir + ansible.builtin.file: + path: /home/{{ ansible_user }}/docker_compose/{{ matrix_service }}/nginx + state: directory + owner: "{{ ansible_user }}" + mode: '0755' + tags: + - nginx + - dir + +- name: Create nginx config + ansible.builtin.template: + src: "nginx/synapse.conf" + dest: /home/{{ ansible_user }}/docker_compose/{{ matrix_service }}/nginx/synapse.conf + owner: "{{ ansible_user }}" + mode: '0644' + tags: + - nginx + - synapse diff --git a/ansible/roles/synapse/templates/nginx/synapse.conf b/ansible/roles/synapse/templates/nginx/synapse.conf index 29a5557..1314f23 100644 --- a/ansible/roles/synapse/templates/nginx/synapse.conf +++ b/ansible/roles/synapse/templates/nginx/synapse.conf @@ -65,7 +65,7 @@ server { deny all; } - # Metrics to master + # Metrics to worker-generic location ~ /synapse-worker-generic/metrics { proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; @@ -80,6 +80,36 @@ server { deny all; } + # Metrics to worker-sync + location ~ /synapse-worker-sync/metrics { + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $http_host; + proxy_pass http://synapse-worker-generic:9000; + + allow 10.161.228.115; + allow 10.161.228.116; + allow 10.161.228.117; + allow 10.161.228.118; + allow 10.161.228.119; + deny all; + } + + # Metrics to worker-federation + location ~ /synapse-worker-federation/metrics { + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Host $http_host; + proxy_pass http://synapse-worker-generic:9000; + + allow 10.161.228.115; + allow 10.161.228.116; + allow 10.161.228.117; + allow 10.161.228.118; + allow 10.161.228.119; + deny all; + } + # All other matrix/synapse requests go to main location ~ /_matrix|/_synapse {