{"id":3159,"date":"2017-07-07T11:36:48","date_gmt":"2017-07-07T15:36:48","guid":{"rendered":"https:\/\/antipaucity.com\/?p=3159"},"modified":"2017-07-07T11:36:48","modified_gmt":"2017-07-07T15:36:48","slug":"ssl-configuration-for-apache-2-4-on-centos-7-with-lets-encrypt","status":"publish","type":"post","link":"https:\/\/merikebi.warrenmyers.com\/?p=3159","title":{"rendered":"ssl configuration for apache 2.4 on centos 7 with let&#8217;s encrypt"},"content":{"rendered":"<p>In follow-up to previous <a href=\"https:\/\/antipaucity.com\/?s=ssl\">posts<\/a> I&#8217;ve had about SSL (specifically with <a href=\"https:\/\/letsencrypt.org\">Let&#8217;s Encrypt<\/a>), here is the set of {{SSL}} configurations I use with all my sites. These, if used correctly,\u00a0<em>should<\/em> score you an &#8220;A+&#8221; with no warnings from <a href=\"https:\/\/ssllabs.com\/ssltest\">ssllabs.com.<\/a> Note: I have an improved <a href=\"https:\/\/antipaucity.com\/2016\/04\/01\/improve-your-entropy-pool-in-linux\">entropy<\/a> package installed (twuewand). This is adapted from the <a href=\"https:\/\/mozilla.github.io\/server-side-tls\/ssl-config-generator\">Mozilla config generator<\/a> with specific options added for individual sites and\/or to match Let&#8217;s Encrypt&#8217;s recommendations.<\/p>\n<p>Please note: you will need to modify the config files to represent your own domains, if you choose to use these as models.<\/p>\n<h3>[\/etc\/httpd\/conf.d\/defaults.conf]<\/h3>\n<pre>#SSL options for all sites\nListen 443\nSSLPassPhraseDialog  builtin\nSSLSessionCache         shmcb:\/var\/cache\/mod_ssl\/scache(512000)\nSSLSessionCacheTimeout  300\nMutex sysvsem default\nSSLRandomSeed startup builtin\nSSLRandomSeed startup file:\/dev\/urandom  1024\n# requires twuewand to be installed\nSSLRandomSeed startup exec:\/bin\/twuewand 64\nSSLRandomSeed connect builtin\nSSLRandomSeed connect file:\/dev\/urandom 1024\nSSLCryptoDevice builtin\n# the SSLSessionTickets directive should work - but on Apache 2.4.6-45, it does not\n#SSLSessionTickets       off\nSSLCompression          off\nSSLHonorCipherOrder\ton\n# there may be an unusual use case for enabling TLS v1.1 or 1 - but I don't know what that would be\nSSLProtocol all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1\nSSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256\nSSLOptions +StrictRequire\nSSLUseStapling on\nSSLStaplingResponderTimeout 5\nSSLStaplingReturnResponderErrors off\nSSLStaplingCache        shmcb:\/var\/run\/ocsp(128000)\n\n#all unknown requests get domain.tld (over http)\n&lt;VirtualHost *:80&gt;\n    DocumentRoot \/var\/html\n    ServerName domain.tld\n    ServerAlias domain.tld *.domain.tld\n    ErrorLog logs\/domain-error_log\n    CustomLog logs\/domain-access_log combined\n    ServerAdmin user@domain.tld\n    &lt;Directory \"\/var\/html\"&gt;\n         Options All +Indexes +FollowSymLinks\n         AllowOverride All\n         Order allow,deny\n         Allow from all\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;\n\nSetOutputFilter DEFLATE\nAddOutputFilterByType DEFLATE text\/html text\/plain text\/xml text\/javascript text\/css text\/php\n<\/pre>\n<h3>[\/etc\/httpd\/conf.d\/z-[sub-]domain-tld.conf]<\/h3>\n<pre>&lt;Virtualhost *:80&gt;\n    ServerName domain.tld\n# could use * instead of www if you don't use subdomains for anything special\/separate\n    ServerAlias domain.tld www.domain.tld\n    Redirect permanent \/ https:\/\/domain.tld\/\n&lt;\/VirtualHost&gt;\n\n&lt;VirtualHost *:443&gt;\n    SSLCertificateFile \/etc\/letsencrypt\/live\/domain.tld\/cert.pem\n    SSLCertificateKeyFile \/etc\/letsencrypt\/live\/domain.tld\/privkey.pem\n# if you put \"fullchain.pem\" here, you will get an error from ssllabs\n    SSLCertificateChainFile \/etc\/letsencrypt\/live\/domain.tld\/chain.pem\n    DocumentRoot \/var\/www\/domain\n    ServerName domain.tld\n    ErrorLog logs\/domain-error_log\n    CustomLog logs\/domain-access_log \\\n          \"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \\\"%r\\\" %b\"\n    ServerAdmin user@domain.tld\n\n# could put this in defaults.conf - I prefer it in each site config\n    SSLEngine on\n\n&lt;Files ~ \"\\.(cgi|shtml|phtml|php3?)$\"&gt;\n    SSLOptions +StdEnvVars\n&lt;\/files&gt;\n&lt;Directory \"\/var\/www\/cgi-bin\"&gt;\n    SSLOptions +StdEnvVars\n&lt;\/Directory&gt;\n\nSetEnvIf User-Agent \".*MSIE.*\" \\\n         nokeepalive ssl-unclean-shutdown \\\n         downgrade-1.0 force-response-1.0\n\n    &lt;Directory \"\/var\/www\/domain\"&gt;\n         Options All +Indexes +FollowSymLinks\n         AllowOverride All\n         Order allow,deny\n         Allow from all\n    &lt;\/Directory&gt;\n\n&lt;\/VirtualHost&gt;\n<\/pre>\n<p>I use the <code>z....conf<\/code> formatting to ensure all site-specific configs are loaded after everything else. That conveniently breaks every site into its own config file, too.<\/p>\n<p>The config file for a non-https site is much simpler:<\/p>\n<pre>&lt;VirtualHost *:80&gt;\n    DocumentRoot \/var\/www\/domain\n    ServerName domain.tld\n    ServerAlias domain.tld *.domain.tld\n    ErrorLog logs\/domain-error_log\n    CustomLog logs\/domain-access_log combined\n    ServerAdmin user@domain.tld\n    &lt;Directory \"\/var\/www\/domain\"&gt;\n         Options All +Indexes +FollowSymLinks\n         AllowOverride All\n         Order allow,deny\n         Allow from all\n    &lt;\/Directory&gt;\n&lt;\/VirtualHost&gt;\n<\/pre>\n<p>If you&#8217;re running something like <a href=\"https:\/\/nextcloud.com\">Nextcloud<\/a>, you may want to turn on <code>Header always set Strict-Transport-Security \"max-age=15552000; includeSubDomains\"<\/code> in the &lt;VirtualHost&amp;gt directive for the site. I haven&#8217;t decided yet if I should put this in <em>every<\/em> SSL-enabled site&#8217;s configs or not.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In follow-up to previous posts I&#8217;ve had about SSL (specifically with Let&#8217;s Encrypt), here is the set of {{SSL}} configurations I use with all my sites. These, if used correctly,\u00a0should score you an &#8220;A+&#8221; with no warnings from ssllabs.com. Note: I have an improved entropy package installed (twuewand). This is adapted from the Mozilla config &hellip;<br \/><a href=\"https:\/\/merikebi.warrenmyers.com\/?p=3159\" class=\"more-link pen_button pen_element_default pen_icon_arrow_double\">Continue reading <span class=\"screen-reader-text\">ssl configuration for apache 2.4 on centos 7 with let&#8217;s encrypt<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[41,46],"tags":[97,166,450,713],"keyring_services":[],"class_list":["post-3159","post","type-post","status-publish","format-standard","hentry","category-technical","category-update","tag-apache","tag-centos","tag-linux","tag-ssl"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/3159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3159"}],"version-history":[{"count":0,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=\/wp\/v2\/posts\/3159\/revisions"}],"wp:attachment":[{"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3159"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/merikebi.warrenmyers.com\/index.php?rest_route=%2Fwp%2Fv2%2Fkeyring_services&post=3159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}