_helper.tpl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. {{- if .enabled }}
  41. # WebDav Share - {{ .name }}
  42. # Description: {{ .description }}
  43. Alias /{{ .name }} "/{{ include "webdav.shares.prefix" $ }}/{{ .name }}"
  44. <Directory "/{{ include "webdav.shares.prefix" $ }}/{{ .name }}">
  45. </Directory>
  46. {{- if .readOnly }}
  47. <Location "/{{ .name }}">
  48. AllowMethods GET OPTIONS PROPFIND
  49. </Location>
  50. {{- end }}
  51. {{- end }}
  52. {{- end }}
  53. # The following directives disable redirects on non-GET requests for
  54. # a directory that does not include the trailing slash. This fixes a
  55. # problem with several clients that do not appropriately handle
  56. # redirects for folders with DAV methods.
  57. BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
  58. BrowserMatch "MS FrontPage" redirect-carefully
  59. BrowserMatch "^WebDrive" redirect-carefully
  60. BrowserMatch "^WebDAVFS/1.[01234]" redirect-carefully
  61. BrowserMatch "^gnome-vfs/1.0" redirect-carefully
  62. BrowserMatch "^XML Spy" redirect-carefully
  63. BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
  64. BrowserMatch " Konqueror/4" redirect-carefully
  65. RequestReadTimeout handshake=0 header=20-40,MinRate=500 body=20,MinRate=500
  66. {{- end -}}
  67. {{/* Included when authType is not "none" */}}
  68. {{- define "webdav.auth.config" -}}
  69. AuthType {{ .Values.webdavConfig.authType }}
  70. AuthName webdav
  71. AuthUserFile "/etc/apache2/webdavht{{ .Values.webdavConfig.authType }}"
  72. Require valid-user
  73. {{- end -}}
  74. {{/* Included in one of the configs (webdav or webdav-ssl)
  75. Used as a healthcheck endpoint */}}
  76. {{- define "webdav.health.config" -}}
  77. <Location "/health">
  78. RewriteEngine On
  79. RewriteRule .* - [R=200]
  80. </Location>
  81. {{- end -}}
  82. {{/* Creates the basic auth password */}}
  83. {{- define "webdav.htauth" -}}
  84. {{- if eq .Values.webdavConfig.authType "basic" -}}
  85. {{- htpasswd .Values.webdavConfig.username .Values.webdavConfig.password -}}
  86. {{- end -}}
  87. {{- end -}}
  88. {{/* Prints the crt path
  89. Used in mountPath of the secret and on the webdav-ssl.conf */}}
  90. {{- define "webdav.path.cert.crt" -}}
  91. {{- print "/etc/certificates/tls.crt" -}}
  92. {{- end -}}
  93. {{/* Prints the key path
  94. Used in mountPath of the secret and on the webdav-ssl.conf */}}
  95. {{- define "webdav.path.cert.key" -}}
  96. {{- print "/etc/certificates/tls.key" -}}
  97. {{- end -}}
  98. {{/* Prints the shares base path inside the container
  99. Used in mountPath of the volume and on the webdav*.conf */}}
  100. {{- define "webdav.shares.prefix" -}}
  101. {{- print "shares" -}}
  102. {{- end -}}