Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

146 строки
5.8 KiB

  1. # SPDX-FileCopyrightText: 2023 - 2024 Jost Alemann
  2. # SPDX-FileCopyrightText: 2024 - 2025 Suguru Hirahara
  3. # SPDX-FileCopyrightText: 2024 Slavi Pantaleev
  4. #
  5. # SPDX-License-Identifier: AGPL-3.0-or-later
  6. server {
  7. # TODO: once per IP and port you should add `reuseport`, if you don't have that in any other nginx config file, add it here by uncommenting the lines below and commenting the one after with `quic` but without `reuseport`
  8. #listen 443 quic reuseport;
  9. listen 443 quic;
  10. listen 443 ssl;
  11. # TODO: if you replaced the line above for port 443 and IPv4, you probably want to do the same for port 443 IPv6 by switching the two lines below
  12. #listen [::]:443 quic reuseport;
  13. listen [::]:443 quic;
  14. listen [::]:443 ssl;
  15. http2 on;
  16. http3 on;
  17. # TODO: add/remove services and their subdomains if you use/don't use them
  18. # this example is using hosting something on the base domain and an Element Web client, so example.com and element.example.com are listed in addition to matrix.example.com
  19. # if you don't use those, you can remove them
  20. # if you use e.g. Etherpad on etherpad.example.com, add etherpad.example.com to the server_name list
  21. server_name example.com matrix.example.com element.example.com;
  22. # needed for matrix rtc
  23. location /livekit-server/ {
  24. proxy_pass http://localhost:81/livekit-server/;
  25. proxy_http_version 1.1;
  26. proxy_set_header Upgrade $http_upgrade;
  27. proxy_set_header Connection "upgrade";
  28. proxy_set_header X-Forwarded-For $remote_addr;
  29. proxy_set_header X-Forwarded-Proto $scheme;
  30. proxy_set_header Host $host;
  31. proxy_set_header X-Real-IP $remote_addr;
  32. # Long timeouts for persistent WebSocket connections
  33. proxy_read_timeout 86400s;
  34. proxy_send_timeout 86400s;
  35. proxy_buffering off;
  36. access_log /var/log/nginx/matrix.access.log;
  37. error_log /var/log/nginx/matrix.error.log;
  38. }
  39. location / {
  40. # note: do not add a path (even a single /) after the port in `proxy_pass`,
  41. # otherwise, nginx will canonicalise the URI and cause signature verification
  42. # errors.
  43. proxy_pass http://localhost:81;
  44. proxy_set_header X-Forwarded-For $remote_addr;
  45. proxy_set_header X-Forwarded-Proto $scheme;
  46. proxy_set_header Host $host;
  47. proxy_set_header X-Real-IP $remote_addr;
  48. access_log /var/log/nginx/matrix.access.log;
  49. error_log /var/log/nginx/matrix.error.log;
  50. # Nginx by default only allows file uploads up to 1M in size
  51. # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
  52. client_max_body_size 50M;
  53. # required for browsers to direct them to quic port
  54. add_header Alt-Svc 'h3=":443"; ma=86400';
  55. }
  56. # TODO: adapt the path to your ssl certificate for the domains listed on server_name
  57. ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
  58. # TODO: adapt the path to your ssl certificate for the domains listed on server_name
  59. ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
  60. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  61. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  62. }
  63. # settings for Matrix federation
  64. server {
  65. # For the federation port
  66. # TODO: once per IP and port you should add `reuseport`, if you don't have that in any other nginx config file, add it here by uncommenting the lines below and commenting the one after with `quic` but without `reuseport`
  67. #listen 8448 quic reuseport;
  68. listen 8448 quic;
  69. listen 8448 ssl default_server;
  70. # TODO: if you replaced the line above for port 8448 and IPv4, you probably want to do the same for port 8448 IPv6 by switching the two lines below
  71. #listen [::]:8448 quic reuseport;
  72. listen [::]:8448 quic;
  73. listen [::]:8448 ssl default_server;
  74. http2 on;
  75. http3 on;
  76. server_name matrix.example.com;
  77. location / {
  78. proxy_pass http://localhost:8449;
  79. proxy_set_header X-Forwarded-For $remote_addr;
  80. proxy_set_header X-Forwarded-Proto $scheme;
  81. proxy_set_header Host $host;
  82. access_log /var/log/nginx/matrix.access.log;
  83. error_log /var/log/nginx/matrix.error.log;
  84. # Nginx by default only allows file uploads up to 1M in size
  85. # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
  86. client_max_body_size 50M;
  87. # required for browsers to direct them to quic port
  88. add_header Alt-Svc 'h3=":8448"; ma=86400';
  89. }
  90. # TODO: adapt the path to your ssl certificate for the domains listed on server_name
  91. ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
  92. # TODO: adapt the path to your ssl certificate for the domains listed on server_name
  93. ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
  94. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  95. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  96. }
  97. # ensure using https
  98. # TODO: remove server blocks that you don't use / add server blocks for domains you do use
  99. server {
  100. if ($host = example.com) {
  101. return 301 https://$host$request_uri;
  102. } # managed by Certbot
  103. server_name example.com;
  104. listen 80;
  105. return 404; # managed by Certbot
  106. }
  107. server {
  108. if ($host = matrix.example.com) {
  109. return 301 https://$host$request_uri;
  110. } # managed by Certbot
  111. server_name matrix.example.com;
  112. listen 80;
  113. return 404; # managed by Certbot
  114. }
  115. server {
  116. if ($host = element.example.com) {
  117. return 301 https://$host$request_uri;
  118. } # managed by Certbot
  119. server_name element.example.com;
  120. listen 80;
  121. return 404; # managed by Certbot
  122. }