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.
 
 

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