_helper.tpl 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. {{/* Webdav HTTP Config */}}
  2. {{- define "webdav.http.config" -}}
  3. Listen {{ .Values.webdavNetwork.httpPort }}
  4. <VirtualHost *:{{ .Values.webdavNetwork.httpPort }}>
  5. {{- include "webdav.health.config" $ | nindent 2 }}
  6. {{- include "webdav.core.config" $ | nindent 2 }}
  7. </VirtualHost>
  8. {{- end -}}
  9. {{/* Webdav HTTPS Config */}}
  10. {{- define "webdav.https.config" -}}
  11. Listen {{ .Values.webdavNetwork.httpsPort }}
  12. <VirtualHost *:{{ .Values.webdavNetwork.httpsPort }}>
  13. {{- if not .Values.webdavNetwork.http }}
  14. {{- include "webdav.health.config" $ | nindent 2 }}
  15. {{- end }}
  16. SSLEngine on
  17. SSLCertificateFile "{{ include "webdav.path.cert.crt" $ }}"
  18. SSLCertificateKeyFile "{{ include "webdav.path.cert.key" $ }}"
  19. SSLProtocol +TLSv1.2 +TLSv1.3
  20. SSLCipherSuite HIGH:MEDIUM
  21. {{- include "webdav.core.config" $ | nindent 2 }}
  22. </VirtualHost>
  23. {{- end -}}
  24. {{/* WebDav Core Config */}}
  25. {{- define "webdav.core.config" -}}
  26. DavLockDB "/usr/local/apache2/var/DavLock"
  27. <Directory />
  28. {{- if ne .Values.webdavConfig.authType "none" }}
  29. {{- include "webdav.auth.config" $ | nindent 2 }}
  30. {{- end }}
  31. Dav On
  32. IndexOptions Charset=utf-8
  33. AddDefaultCharset UTF-8
  34. AllowOverride None
  35. Order allow,deny
  36. Allow from all
  37. Options Indexes FollowSymLinks
  38. </Directory>
  39. {{- range .Values.webdavStorage.shares }}
  40. {{ $bytesGB := 1073741824 }}
  41. {{- if .enabled }}
  42. # WebDav Share - {{ .name }}
  43. # Description: {{ .description }}
  44. Alias /{{ .name }} "/{{ include "webdav.shares.prefix" $ }}/{{ .name }}"
  45. <Directory "/{{ include "webdav.shares.prefix" $ }}/{{ .name }}">
  46. {{- $maxReqBody := 1 -}}
  47. {{- if not (kindIs "invalid" .maxRequestBodySizeInGB) -}}
  48. {{- $maxReqBody = mul .maxRequestBodySizeInGB $bytesGB -}}
  49. {{- end }}
  50. LimitRequestBody {{ $maxReqBody }}
  51. </Directory>
  52. {{- if .readOnly }}
  53. <Location "/{{ .name }}">
  54. AllowMethods GET OPTIONS PROPFIND
  55. </Location>
  56. {{- end }}
  57. {{- end }}
  58. {{- end }}
  59. # The following directives disable redirects on non-GET requests for
  60. # a directory that does not include the trailing slash. This fixes a
  61. # problem with several clients that do not appropriately handle
  62. # redirects for folders with DAV methods.
  63. BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
  64. BrowserMatch "MS FrontPage" redirect-carefully
  65. BrowserMatch "^WebDrive" redirect-carefully
  66. BrowserMatch "^WebDAVFS/1.[01234]" redirect-carefully
  67. BrowserMatch "^gnome-vfs/1.0" redirect-carefully
  68. BrowserMatch "^XML Spy" redirect-carefully
  69. BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
  70. BrowserMatch " Konqueror/4" redirect-carefully
  71. RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500
  72. {{- end -}}
  73. {{/* Included when authType is not "none" */}}
  74. {{- define "webdav.auth.config" -}}
  75. AuthType {{ .Values.webdavConfig.authType }}
  76. AuthName webdav
  77. AuthUserFile "/etc/apache2/webdavht{{ .Values.webdavConfig.authType }}"
  78. Require valid-user
  79. {{- end -}}
  80. {{/* Included in one of the configs (webdav or webdav-ssl)
  81. Used as a healthcheck endpoint */}}
  82. {{- define "webdav.health.config" -}}
  83. <Location "/health">
  84. RewriteEngine On
  85. RewriteRule .* - [R=200]
  86. </Location>
  87. {{- end -}}
  88. {{/* Creates the basic auth password */}}
  89. {{- define "webdav.htauth" -}}
  90. {{- if eq .Values.webdavConfig.authType "basic" -}}
  91. {{- htpasswd .Values.webdavConfig.username .Values.webdavConfig.password -}}
  92. {{- end -}}
  93. {{- end -}}
  94. {{/* Prints the crt path
  95. Used in mountPath of the secret and on the webdav-ssl.conf */}}
  96. {{- define "webdav.path.cert.crt" -}}
  97. {{- print "/etc/certificates/tls.crt" -}}
  98. {{- end -}}
  99. {{/* Prints the key path
  100. Used in mountPath of the secret and on the webdav-ssl.conf */}}
  101. {{- define "webdav.path.cert.key" -}}
  102. {{- print "/etc/certificates/tls.key" -}}
  103. {{- end -}}
  104. {{/* Prints the shares base path inside the container
  105. Used in mountPath of the volume and on the webdav*.conf */}}
  106. {{- define "webdav.shares.prefix" -}}
  107. {{- print "shares" -}}
  108. {{- end -}}