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.
 
 

94 lines
3.7 KiB

  1. #jinja2: lstrip_blocks: True
  2. # This is a custom nginx configuration file that we use in the container (instead of the default one),
  3. # because it allows us to run nginx with a non-root user.
  4. #
  5. # For this to work, the default vhost file (`/etc/nginx/conf.d/default.conf`) also needs to be removed.
  6. #
  7. # The following changes have been done compared to a default nginx configuration file:
  8. # - various temp paths are changed to `/tmp`, so that a non-root user can write to them
  9. # - the `user` directive was removed, as we don't want nginx to switch users
  10. # load_module directives must be first or nginx will choke with:
  11. # > [emerg] "load_module" directive is specified too late.
  12. {% if matrix_synapse_reverse_proxy_companion_njs_enabled %}
  13. load_module modules/ngx_http_js_module.so;
  14. {% endif %}
  15. worker_processes {{ matrix_synapse_reverse_proxy_companion_worker_processes }};
  16. error_log /var/log/nginx/error.log warn;
  17. pid /tmp/nginx.pid;
  18. {% for configuration_block in matrix_synapse_reverse_proxy_companion_additional_configuration_blocks %}
  19. {{- configuration_block }}
  20. {% endfor %}
  21. events {
  22. worker_connections {{ matrix_synapse_reverse_proxy_companion_worker_connections }};
  23. {% for configuration_block in matrix_synapse_reverse_proxy_companion_event_additional_configuration_blocks %}
  24. {{- configuration_block }}
  25. {% endfor %}
  26. }
  27. http {
  28. proxy_temp_path /tmp/proxy_temp;
  29. client_body_temp_path /tmp/client_temp;
  30. fastcgi_temp_path /tmp/fastcgi_temp;
  31. uwsgi_temp_path /tmp/uwsgi_temp;
  32. scgi_temp_path /tmp/scgi_temp;
  33. include /etc/nginx/mime.types;
  34. default_type application/octet-stream;
  35. {% if matrix_synapse_reverse_proxy_companion_njs_enabled %}
  36. js_path /njs/;
  37. {% endif %}
  38. {% if matrix_synapse_reverse_proxy_companion_whoami_sync_worker_router_enabled %}
  39. # njs module for whoami-based sync worker routing
  40. js_import whoami_sync_worker_router from whoami_sync_worker_router.js;
  41. js_shared_dict_zone zone=whoami_sync_worker_router_cache:{{ matrix_synapse_reverse_proxy_companion_whoami_sync_worker_router_cache_size_mb }}m;
  42. {% endif %}
  43. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  44. '$status $body_bytes_sent "$http_referer" '
  45. '"$http_user_agent" "$http_x_forwarded_for"';
  46. {% if matrix_synapse_reverse_proxy_companion_access_log_enabled %}
  47. access_log /var/log/nginx/access.log main;
  48. {% else %}
  49. access_log off;
  50. {% endif %}
  51. {% if matrix_synapse_reverse_proxy_companion_access_log_syslog_integration_enabled %}
  52. log_format prometheus_fmt 'matrix-synapse-reverse-proxy-companion $server_name - $upstream_addr - $remote_addr - $remote_user [$time_local] '
  53. '$host "$request" '
  54. '$status "$http_referer" '
  55. '"$http_user_agent" "$http_x_forwarded_for"';
  56. access_log syslog:server={{ matrix_synapse_reverse_proxy_companion_access_log_syslog_integration_server_port }},tag={{ matrix_synapse_reverse_proxy_companion_access_log_syslog_integration_tag }} prometheus_fmt;
  57. {% endif %}
  58. {% if not matrix_synapse_reverse_proxy_companion_access_log_enabled and not matrix_synapse_reverse_proxy_companion_access_log_syslog_integration_enabled %}
  59. access_log off;
  60. {% endif %}
  61. proxy_connect_timeout {{ matrix_synapse_reverse_proxy_companion_proxy_connect_timeout }};
  62. proxy_send_timeout {{ matrix_synapse_reverse_proxy_companion_proxy_send_timeout }};
  63. proxy_read_timeout {{ matrix_synapse_reverse_proxy_companion_proxy_read_timeout }};
  64. send_timeout {{ matrix_synapse_reverse_proxy_companion_send_timeout }};
  65. sendfile on;
  66. #tcp_nopush on;
  67. keepalive_timeout 65;
  68. server_tokens off;
  69. {# Map directive needed for proxied WebSocket upgrades #}
  70. map $http_upgrade $connection_upgrade {
  71. default upgrade;
  72. '' close;
  73. }
  74. include /etc/nginx/conf.d/*.conf;
  75. }