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

123 строки
5.0 KiB

  1. # SPDX-FileCopyrightText: 2024 MDAD Team and contributors
  2. #
  3. # SPDX-License-Identifier: AGPL-3.0-or-later
  4. server {
  5. # 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`
  6. #listen 443 quic reuseport;
  7. listen 443 quic;
  8. listen 443 ssl;
  9. # 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
  10. #listen [::]:443 quic reuseport;
  11. listen [::]:443 quic;
  12. listen [::]:443 ssl;
  13. http2 on;
  14. http3 on;
  15. # TODO: add/remove services and their subdomains if you use/don't use them
  16. # 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
  17. # if you don't use those, you can remove them
  18. # if you use e.g. dimension on dimension.example.com, add dimension.example.com to the server_name list
  19. server_name example.com matrix.example.com element.example.com;
  20. location / {
  21. # note: do not add a path (even a single /) after the port in `proxy_pass`,
  22. # otherwise, nginx will canonicalise the URI and cause signature verification
  23. # errors.
  24. proxy_pass http://localhost:81;
  25. proxy_set_header X-Forwarded-For $remote_addr;
  26. proxy_set_header X-Forwarded-Proto $scheme;
  27. proxy_set_header Host $host;
  28. proxy_set_header X-Real-IP $remote_addr;
  29. access_log /var/log/nginx/matrix.access.log;
  30. error_log /var/log/nginx/matrix.error.log;
  31. # Nginx by default only allows file uploads up to 1M in size
  32. # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
  33. client_max_body_size 50M;
  34. # required for browsers to direct them to quic port
  35. add_header Alt-Svc 'h3=":443"; ma=86400';
  36. }
  37. # TODO: adapt the path to your ssl certificate for the domains listed on server_name
  38. ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
  39. # TODO: adapt the path to your ssl certificate for the domains listed on server_name
  40. ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
  41. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  42. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  43. }
  44. # settings for Matrix federation
  45. server {
  46. # For the federation port
  47. # 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`
  48. #listen 8448 quic reuseport;
  49. listen 8448 quic;
  50. listen 8448 ssl default_server;
  51. # 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
  52. #listen [::]:8448 quic reuseport;
  53. listen [::]:8448 quic;
  54. listen [::]:8448 ssl default_server;
  55. http2 on;
  56. http3 on;
  57. server_name matrix.example.com;
  58. location / {
  59. proxy_pass http://localhost:8449;
  60. proxy_set_header X-Forwarded-For $remote_addr;
  61. proxy_set_header X-Forwarded-Proto $scheme;
  62. proxy_set_header Host $host;
  63. access_log /var/log/nginx/matrix.access.log;
  64. error_log /var/log/nginx/matrix.error.log;
  65. # Nginx by default only allows file uploads up to 1M in size
  66. # Increase client_max_body_size to match max_upload_size defined in homeserver.yaml
  67. client_max_body_size 50M;
  68. # required for browsers to direct them to quic port
  69. add_header Alt-Svc 'h3=":8448"; ma=86400';
  70. }
  71. # TODO: adapt the path to your ssl certificate for the domains listed on server_name
  72. ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
  73. # TODO: adapt the path to your ssl certificate for the domains listed on server_name
  74. ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
  75. include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
  76. ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
  77. }
  78. # ensure using https
  79. # TODO: remove server blocks that you don't use / add server blocks for domains you do use
  80. server {
  81. if ($host = example.com) {
  82. return 301 https://$host$request_uri;
  83. } # managed by Certbot
  84. server_name example.com;
  85. listen 80;
  86. return 404; # managed by Certbot
  87. }
  88. server {
  89. if ($host = matrix.example.com) {
  90. return 301 https://$host$request_uri;
  91. } # managed by Certbot
  92. server_name matrix.example.com;
  93. listen 80;
  94. return 404; # managed by Certbot
  95. }
  96. server {
  97. if ($host = element.example.com) {
  98. return 301 https://$host$request_uri;
  99. } # managed by Certbot
  100. server_name element.example.com;
  101. listen 80;
  102. return 404; # managed by Certbot
  103. }