Edit [[Template:Securevhost.conf|EPRINTS_PATH/archives/REPOID/ssl/securevhost.conf]] and add the following HSTS header. The max-age variable is a time in seconds for how long the HSTS settings should be remembered by the browser. 15780000 is six months, which is a long time, you may want to set it to a shorter time while testing.

+

Edit [[Template:Securevhost.conf|EPRINTS_PATH/archives/REPOID/ssl/securevhost.conf]] and add the following HSTS header after ther <tt>ServerName</tt> line. The max-age variable is a time in seconds for how long the HSTS settings should be remembered by the browser. 15780000 is six months, which is a long time, you may want to set it to a shorter time while testing.

Header set Strict-Transport-Security "max-age=15780000"

Header set Strict-Transport-Security "max-age=15780000"

Line 56:

Line 56:

==== Add 301 redirects to secure port from HTTP (port 80) ====

==== Add 301 redirects to secure port from HTTP (port 80) ====

−

By following the instructions above, if you use [https://github.com/eprints/eprints/commit/c29574dbdcd49c67f3aea522998960f2eb19f544 this patch] or are running [https://github.com/eprints/eprints the latest revision of EPrints on GitHub], <tt>/bin/generate_apacheconf</tt> will generate an <tt>/cfg/apache/REPOID.conf</tt>, which automatically redirects HTTP to HTTPS. Otherwise, this can be achieved by modifying <tt>/cfg/apache/REPOID.conf</tt> to the following, substituting your domain as appropriate:

+

By making the changes to the archive's <tt>cfg.d/10_core.pl</tt>, if you use [https://github.com/eprints/eprints/commit/c29574dbdcd49c67f3aea522998960f2eb19f544 this patch] or are running [https://github.com/eprints/eprints the latest revision of EPrints on GitHub], <tt>/bin/generate_apacheconf</tt> will generate an <tt>/cfg/apache/REPOID.conf</tt>, which automatically redirects HTTP to HTTPS. Otherwise, this can be achieved by modifying <tt>/cfg/apache/REPOID.conf</tt> to the following, substituting your domain as appropriate:

Google Best Practices for HTTPS

HSTS

To summarize how HSTS works, if a browser (Chrome, Firefix, IE) sees the HSTS header in the HTTPS response, and there are no certificate errors or mixed content warnings or anything (if it is green), then the next time a user of that browser requests the HTTP page of that site, the browser will modify the request from an HTTP to a HTTPS request. The browser will remember that setting for as long as you specify max-age to be. This means that even with HSTS, it is still possible to request and receive content over HTTP. To close that down, a server redirect is necessary, so those browsers that haven’t seen the HSTS header in the past that happen to try to go to HTTP will get that initial redirect to HTTPS.

Implementing HTTPS-only with HSTS on an EPrints repository

Changes to archive's cfg.d/10_core.pl

Initialize the following variables to be the https URL (i.e., https://YOUR-REPOSITORY-DOMAIN)

Remove any hard coded links to HTTP
If you have Google Search included as an XPAGE file,
call on the Google API (and any other APIs) using HTTPS.

Changes to Apache config files

Add the HSTS header

Edit EPRINTS_PATH/archives/REPOID/ssl/securevhost.conf and add the following HSTS header after ther ServerName line. The max-age variable is a time in seconds for how long the HSTS settings should be remembered by the browser. 15780000 is six months, which is a long time, you may want to set it to a shorter time while testing.

Header set Strict-Transport-Security "max-age=15780000"

Include this file from the core apache conf file for the secure port (443) in /etc/

Add 301 redirects to secure port from HTTP (port 80)

By making the changes to the archive's cfg.d/10_core.pl, if you use this patch or are running the latest revision of EPrints on GitHub, /bin/generate_apacheconf will generate an /cfg/apache/REPOID.conf, which automatically redirects HTTP to HTTPS. Otherwise, this can be achieved by modifying /cfg/apache/REPOID.conf to the following, substituting your domain as appropriate: