Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

62 lines
2.9 KiB

  1. - set_fact:
  2. matrix_systemd_services_list: "{{ matrix_systemd_services_list + ['matrix-registration.service'] }}"
  3. when: matrix_registration_enabled|bool
  4. - block:
  5. - name: Fail if matrix-nginx-proxy role already executed
  6. fail:
  7. msg: >-
  8. Trying to append matrix-registration's reverse-proxying configuration to matrix-nginx-proxy,
  9. but it's pointless since the matrix-nginx-proxy role had already executed.
  10. To fix this, please change the order of roles in your plabook,
  11. so that the matrix-nginx-proxy role would run after the matrix-registration role.
  12. when: matrix_nginx_proxy_role_executed|default(False)|bool
  13. - name: Generate matrix-registration proxying configuration for matrix-nginx-proxy
  14. set_fact:
  15. matrix_registration_matrix_nginx_proxy_configuration: |
  16. rewrite ^{{ matrix_registration_public_endpoint }}$ $scheme://$server_name{{ matrix_registration_public_endpoint }}/ permanent;
  17. rewrite ^{{ matrix_registration_public_endpoint }}/$ $scheme://$server_name{{ matrix_registration_public_endpoint }}/register redirect;
  18. location ~ ^{{ matrix_registration_public_endpoint }}/(.*) {
  19. {% if matrix_nginx_proxy_enabled|default(False) %}
  20. {# Use the embedded DNS resolver in Docker containers to discover the service #}
  21. resolver 127.0.0.11 valid=5s;
  22. set $backend "matrix-registration:5000";
  23. proxy_pass http://$backend/$1;
  24. {% else %}
  25. {# Generic configuration for use outside of our container setup #}
  26. proxy_pass http://127.0.0.1:8767/$1;
  27. {% endif %}
  28. {#
  29. Workaround matrix-registration serving the background image at /static
  30. (see https://github.com/ZerataX/matrix-registration/issues/47)
  31. #}
  32. sub_filter_once off;
  33. sub_filter_types text/css;
  34. sub_filter "/static/" "{{ matrix_registration_public_endpoint }}/static/";
  35. }
  36. - name: Register matrix-registration proxying configuration with matrix-nginx-proxy
  37. set_fact:
  38. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks: |
  39. {{
  40. matrix_nginx_proxy_proxy_matrix_additional_server_configuration_blocks|default([])
  41. +
  42. [matrix_registration_matrix_nginx_proxy_configuration]
  43. }}
  44. tags:
  45. - always
  46. when: matrix_registration_enabled|bool
  47. - name: Warn about reverse-proxying if matrix-nginx-proxy not used
  48. debug:
  49. msg: >-
  50. NOTE: You've enabled the matrix-registration tool but are not using the matrix-nginx-proxy
  51. reverse proxy.
  52. Please make sure that you're proxying the `{{ matrix_registration_public_endpoint }}`
  53. URL endpoint to the matrix-registration container.
  54. You can expose the container's port using the `matrix_registration_container_http_host_bind_port` variable.
  55. when: "matrix_registration_enabled|bool and matrix_nginx_proxy_enabled is not defined"