|
| 1 | +#!/bin/bash -e |
| 2 | + |
| 3 | +# try to enable mod, if not available just continue |
| 4 | +a2enmod ssl || true |
| 5 | + |
| 6 | +# tweak mod_evasive defaults |
| 7 | +CONF=/etc/apache2/mods-available/ssl.conf |
| 8 | +if [[ -f "$CONF" ]]; then |
| 9 | + # tighten ssl protocol support |
| 10 | + ssl_protocol="# Hardened TKL default\nSSLProtocol -all +TLSv1.2 +TLSv1.3" |
| 11 | + sed -Ei "\|^SSLProtocol| s|^(.*)|#\1\n$ssl_protocol|" "$CONF" |
| 12 | + |
| 13 | + cipher_suites=$(cat <<EOF |
| 14 | +# Explict Cipher suites recommended by Mozilla |
| 15 | +# https://ssl-config.mozilla.org/#server=apache&version=2.4.65&config=intermediate&openssl=3.5.1&guideline=5.7 |
| 16 | +# (updated by TurnKey "common/conf/turnkey.d/zz-ssl-ciphers" script) |
| 17 | +SSLCipherSuite ZZ_SSL_CIPHERS |
| 18 | +EOF |
| 19 | + ) |
| 20 | + sed -Ei "\|^SSLCipherSuite| s|^(.*)|#\1\n$cipher_suites|" "$CONF" |
| 21 | + |
| 22 | + cat >> "$CONF" <<EOF |
| 23 | +
|
| 24 | +# Additional default TKL Apache SSL/TLS config |
| 25 | +
|
| 26 | +SSLOpenSSLConfCmd Curves X25519:prime256v1:secp384r1 |
| 27 | +
|
| 28 | +# Explictly disable SSL compression (should default to off anyway...) |
| 29 | +# Note enabling SSL compression makes Apache vulnerable to CRIME attack. |
| 30 | +SSLCompression off |
| 31 | +
|
| 32 | +# Default certificate file to use (provided by TurnKey) |
| 33 | +SSLCertificateFile /etc/ssl/private/cert.pem |
| 34 | +# Default TKL cert.pem includes key so this can remain unset |
| 35 | +#SSLCertificateKeyFile /etc/ssl/private/cert.key |
| 36 | +
|
| 37 | +# enable HTTP/2, if available |
| 38 | +Protocols h2 http/1.1 |
| 39 | +
|
| 40 | +# OCSP Stapling |
| 41 | +SSLUseStapling On |
| 42 | +SSLStaplingCache "shmcb:logs/ssl_stapling(32768)" |
| 43 | +
|
| 44 | +# HTTP Strict Transport Security (mod_headers is required) |
| 45 | +Header always set Strict-Transport-Security "max-age=63072000" |
| 46 | +
|
| 47 | +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet |
| 48 | +EOF |
| 49 | +else |
| 50 | + echo "fatal: conf file $CONF not found" >&2 |
| 51 | + exit 1 |
| 52 | +fi |
0 commit comments