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.
 
 

270 lines
9.4 KiB

  1. (cors) {
  2. @cors_preflight method OPTIONS
  3. handle @cors_preflight {
  4. header Access-Control-Allow-Origin "{args.0}"
  5. header Access-Control-Allow-Methods "HEAD, GET, POST, PUT, PATCH, DELETE"
  6. header Access-Control-Allow-Headers "Content-Type, Authorization"
  7. header Access-Control-Max-Age "3600"
  8. }
  9. }
  10. matrix.DOMAIN.tld {
  11. # creates letsencrypt certificate
  12. # tls your@email.com
  13. @identity {
  14. path /_matrix/identity/*
  15. }
  16. @noidentity {
  17. not path /_matrix/identity/*
  18. }
  19. @search {
  20. path /_matrix/client/r0/user_directory/search/*
  21. }
  22. @nosearch {
  23. not path /_matrix/client/r0/user_directory/search/*
  24. }
  25. @static {
  26. path /matrix/static-files/*
  27. }
  28. @nostatic {
  29. not path /matrix/static-files/*
  30. }
  31. @wellknown {
  32. path /.well-known/matrix/*
  33. }
  34. header {
  35. # Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS
  36. Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  37. # Enable cross-site filter (XSS) and tell browser to block detected attacks
  38. X-XSS-Protection "1; mode=block"
  39. # Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
  40. X-Content-Type-Options "nosniff"
  41. # Disallow the site to be rendered within a frame (clickjacking protection)
  42. X-Frame-Options "DENY"
  43. # X-Robots-Tag
  44. X-Robots-Tag "noindex, noarchive, nofollow"
  45. }
  46. # Cache
  47. header @static {
  48. # Cache
  49. Cache-Control "public, max-age=31536000"
  50. defer
  51. }
  52. # identity
  53. handle @identity {
  54. reverse_proxy localhost:8090 {
  55. header_up X-Forwarded-Port {http.request.port}
  56. header_up X-Forwarded-Proto {http.request.scheme}
  57. header_up X-Forwarded-TlsProto {tls_protocol}
  58. header_up X-Forwarded-TlsCipher {tls_cipher}
  59. header_up X-Forwarded-HttpsProto {proto}
  60. }
  61. }
  62. # search
  63. handle @search {
  64. reverse_proxy localhost:8090 {
  65. header_up X-Forwarded-Port {http.request.port}
  66. header_up X-Forwarded-Proto {http.request.scheme}
  67. header_up X-Forwarded-TlsProto {tls_protocol}
  68. header_up X-Forwarded-TlsCipher {tls_cipher}
  69. header_up X-Forwarded-HttpsProto {proto}
  70. }
  71. }
  72. handle @wellknown {
  73. encode zstd gzip
  74. root * /matrix/static-files
  75. header Cache-Control max-age=14400
  76. header Content-Type application/json
  77. header Access-Control-Allow-Origin *
  78. file_server
  79. }
  80. # If you have other well-knowns already handled by your base domain, you can replace the above block by this one, along with the replacement suggested in the base domain
  81. #handle @wellknown {
  82. # # .well-known is handled by base domain
  83. # reverse_proxy https://DOMAIN.tld {
  84. # header_up Host {http.reverse_proxy.upstream.hostport}
  85. #}
  86. handle {
  87. encode zstd gzip
  88. reverse_proxy localhost:8008 {
  89. header_up X-Forwarded-Port {http.request.port}
  90. header_up X-Forwarded-Proto {http.request.scheme}
  91. header_up X-Forwarded-TlsProto {tls_protocol}
  92. header_up X-Forwarded-TlsCipher {tls_cipher}
  93. header_up X-Forwarded-HttpsProto {proto}
  94. }
  95. }
  96. }
  97. matrix.DOMAIN.tld:8448 {
  98. handle {
  99. encode zstd gzip
  100. reverse_proxy 127.0.0.1:8048 {
  101. header_up X-Forwarded-Port {http.request.port}
  102. header_up X-Forwarded-Proto {http.request.scheme}
  103. header_up X-Forwarded-TlsProto {tls_protocol}
  104. header_up X-Forwarded-TlsCipher {tls_cipher}
  105. header_up X-Forwarded-HttpsProto {proto}
  106. }
  107. }
  108. }
  109. element.DOMAIN.tld {
  110. # creates letsencrypt certificate
  111. # tls your@email.com
  112. import cors https://*.DOMAIN.tld
  113. header {
  114. # Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS
  115. Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  116. # Enable cross-site filter (XSS) and tell browser to block detected attacks
  117. X-XSS-Protection "1; mode=block"
  118. # Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
  119. X-Content-Type-Options "nosniff"
  120. # Disallow the site to be rendered within a frame (clickjacking protection)
  121. X-Frame-Options "DENY"
  122. # If using integrations that add frames to Element, such as Dimension and its integrations running on the same domain, it can be a good idea to limit sources allowed to be rendered
  123. # Content-Security-Policy frame-src https://*.DOMAIN.tld
  124. # X-Robots-Tag
  125. X-Robots-Tag "noindex, noarchive, nofollow"
  126. }
  127. handle {
  128. encode zstd gzip
  129. reverse_proxy localhost:8765 {
  130. header_up X-Forwarded-Port {http.request.port}
  131. header_up X-Forwarded-Proto {http.request.scheme}
  132. header_up X-Forwarded-TlsProto {tls_protocol}
  133. header_up X-Forwarded-TlsCipher {tls_cipher}
  134. header_up X-Forwarded-HttpsProto {proto}
  135. }
  136. }
  137. #dimension.DOMAIN.tld {
  138. #
  139. # # creates letsencrypt certificate
  140. # # tls your@email.com
  141. #
  142. # import cors https://*.DOMAIN.tld
  143. #
  144. # header {
  145. # # Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS
  146. # Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  147. # # Enable cross-site filter (XSS) and tell browser to block detected attacks
  148. # X-XSS-Protection "1; mode=block"
  149. # # Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
  150. # X-Content-Type-Options "nosniff"
  151. # # Only allow same base domain to render this website in a frame; Can be removed if the client (Element for example) is hosted on another domain (clickjacking protection)
  152. # Content-Security-Policy frame-ancestors https://*.DOMAIN.tld
  153. # # X-Robots-Tag
  154. # X-Robots-Tag "noindex, noarchive, nofollow"
  155. # }
  156. #
  157. # handle {
  158. # encode zstd gzip
  159. #
  160. # reverse_proxy localhost:8184 {
  161. # header_up X-Forwarded-Port {http.request.port}
  162. # header_up X-Forwarded-Proto {http.request.scheme}
  163. # header_up X-Forwarded-TlsProto {tls_protocol}
  164. # header_up X-Forwarded-TlsCipher {tls_cipher}
  165. # header_up X-Forwarded-HttpsProto {proto}
  166. # }
  167. # }
  168. #}
  169. #jitsi.DOMAIN.tld {
  170. #
  171. # creates letsencrypt certificate
  172. # tls your@email.com
  173. #
  174. # import cors https://*.DOMAIN.tld
  175. #
  176. # header {
  177. # # Enable HTTP Strict Transport Security (HSTS) to force clients to always connect via HTTPS
  178. # Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  179. #
  180. # # Enable cross-site filter (XSS) and tell browser to block detected attacks
  181. # X-XSS-Protection "1; mode=block"
  182. #
  183. # # Prevent some browsers from MIME-sniffing a response away from the declared Content-Type
  184. # X-Content-Type-Options "nosniff"
  185. # # Only allow same base domain to render this website in a frame; Can be removed if the client (Element for example) is hosted on another domain
  186. # Content-Security-Policy frame-ancestors https://*.DOMAIN.tld
  187. #
  188. # # Disable some features
  189. # Feature-Policy "accelerometer 'none';ambient-light-sensor 'none'; autoplay 'none';camera 'none';encrypted-media 'none';focus-without-user-activation 'none'; geolocation 'none';gyroscope #'none';magnetometer 'none';microphone 'none';midi 'none';payment 'none';picture-in-picture 'none'; speaker 'none';sync-xhr 'none';usb 'none';vr 'none'"
  190. #
  191. # # Referer
  192. # Referrer-Policy "no-referrer"
  193. #
  194. # # X-Robots-Tag
  195. # X-Robots-Tag "none"
  196. #
  197. # # Remove Server header
  198. # -Server
  199. # }
  200. #
  201. # handle {
  202. # encode zstd gzip
  203. #
  204. # reverse_proxy 127.0.0.1:13080 {
  205. # header_up X-Forwarded-Port {http.request.port}
  206. # header_up X-Forwarded-Proto {http.request.scheme}
  207. # header_up X-Forwarded-TlsProto {tls_protocol}
  208. # header_up X-Forwarded-TlsCipher {tls_cipher}
  209. # header_up X-Forwarded-HttpsProto {proto}
  210. # }
  211. # }
  212. #}
  213. #DOMAIN.com {
  214. # Uncomment this if you are following "(Option 3): Setting up reverse-proxying of the well-known files from the base domain's server to the Matrix server" of https://github.com/spantaleev/matrix-docker-ansible-deploy/blob/master/docs/configuring-well-known.md#option-3-setting-up-reverse-proxying-of-the-well-known-files-from-the-base-domains-server-to-the-matrix-server
  215. # @wellknown {
  216. # path /.well-known/matrix/*
  217. # }
  218. #
  219. # handle @wellknown {
  220. # reverse_proxy https://matrix.DOMAIN.com {
  221. # header_up Host {http.reverse_proxy.upstream.hostport}
  222. # }
  223. # }
  224. # # If you have other well-knowns already handled by your base domain, you can replace the above block by this one, along with the replacement suggested in the matrix subdomain
  225. # # handle /.well-known/* {
  226. # # encode zstd gzip
  227. # # header Cache-Control max-age=14400
  228. # # header Content-Type application/json
  229. # # header Access-Control-Allow-Origin *
  230. # #}
  231. #
  232. # # Configration for the base domain goes here
  233. # # handle {
  234. # # header -Server
  235. # # encode zstd gzip
  236. # # reverse_proxy localhost:4020
  237. # # }
  238. #}