Skip to content

Instantly share code, notes, and snippets.

@crushcafeteria
Created April 20, 2016 12:05
Show Gist options
  • Save crushcafeteria/950201e3cdb785204a326d0dcf95b11f to your computer and use it in GitHub Desktop.
Save crushcafeteria/950201e3cdb785204a326d0dcf95b11f to your computer and use it in GitHub Desktop.
How to set up an SSL virtual host with Apache2 and LetsEncrypt CA
# Redirect non-SSL traffic to SSL site
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
Redirect permanent / https://example.com/
</VirtualHost>
# SSL Site
<VirtualHost *:443>
ServerAdmin nelson@blackpay.co.ke
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html/{example_siteroot}
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Inject your SSL certificates from LetsEncrypt
SSLEngine on
SSLCertificateKeyFile /etc/letsencrypt/live/www.ameyo.me/privkey.pem
SSLCertificateFile /etc/letsencrypt/live/www.ameyo.me/cert.pem
SSLCertificateChainFile /etc/letsencrypt/live/www.ameyo.me/chain.pem
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
<Directory /var/www/html/{example_siteroot}>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment