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.
 
 

119 lines
4.9 KiB

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