diff --git a/defaults/main.yaml b/defaults/main.yaml
index fe01324..7314f71 100644
--- a/defaults/main.yaml
+++ b/defaults/main.yaml
@@ -14,6 +14,8 @@ nextcloud_www_path: '/var/www/nextcloud/'
nextcloud_ssl: true
nextcloud_ssl_certificate_path: "/etc/ssl/certs/ssl-cert-snakeoil.pem"
nextcloud_ssl_key_path: "/etc/ssl/private/ssl-cert-snakeoil.key"
+nextcloud_hsts: true
+nextcloud_hsts_preload: false
# Apache configuration
diff --git a/templates/apache2_ssl_nextcloud.conf.j2 b/templates/apache2_ssl_nextcloud.conf.j2
index c12d3d4..6f99d3d 100644
--- a/templates/apache2_ssl_nextcloud.conf.j2
+++ b/templates/apache2_ssl_nextcloud.conf.j2
@@ -31,6 +31,12 @@
SSLOptions +StdEnvVars
+
+{% if nextcloud_hsts %}
+
+ Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains{% if nextcloud_hsts_preload %}; preload{% endif %}"
+
+{% endif %}