I'm trying to figure out how to redirect http traffic to https. I running apache2 with varnish. Someone more knowledgeable than me has set this up for me on other websites. I've set up a new site to mimic the apache config for one of the known good sites that has redirection working but I'm not having any luck getting it to work for the new site; http traffic just pulls up as regular http traffic in the browser. Here is my apache config file:
<VirtualHost *>
ServerName thesite.org
ServerAlias *.thesite.org
Use letsencrypt-challenge thesite.org
Use ssl-upgrade thesite.org
# replace the brackets and string with the appropriate string as indicated
DocumentRoot /home/sites/wp_sites/thesite
ScriptAlias /cgi-bin/ /home/thesite/cgi-bin/
ScriptAlias /cgi /home/thesite/cgi-bin/
# not a typo, the user name is entered twice in the line below
SuexecUserGroup thesite thesite
# THIS HAS TO BE CORRECT. Double and triple check your typing here!
Use site_logging thesite
# These settings are the same for every site
ErrorDocument 404 /index.php
Use default_expire
Options IncludesNOEXEC FollowSymLinks
Use default_deny
Use default_php_fastcgi
</VirtualHost>
<VirtualHost *:443>
ServerName thesite.org
ServerAlias *.thesite.org
Use letsencrypt-challenge thesite.org
Use letsencrypt-ssl thesite.org
Use ssl-proxy thesite.org
#ProxyPass / http://thesite.org/
# ProxyPassReverse / http://thesite.org/
</VirtualHost>
And here are the relevant macros:
<Macro ssl-redirect $server_redirect>
RewriteCond expr "%{HTTP_HOST} != '$server_redirect'"
RewriteRule /?(.*) "https://$server_redirect/$1" [L,NE]
</Macro>
<Macro ssl-upgrade $server_upgrade>
Use ssl-redirect "$server_upgrade"
<If "! req_novary('X-Forwarded-Proto') =~ /https/">
Redirect / "https://$server_upgrade/"
</If>
</Macro>
<Macro ssl-proxy $server_proxy>
Use letsencrypt-challenge "$server_proxy"
Use letsencrypt-ssl "$server_proxy"
Use ssl-redirect "$server_proxy"
ProxyPass / "http://$server_proxy/"
ProxyPassReverse / "http://$server_proxy/"
</Macro>
<Macro letsencrypt-ssl $server>
SSLEngine On
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"
SSLCertificateFile "/etc/letsencrypt/live/$server/fullchain.pem"
SSLCertificateKeyFile "/etc/letsencrypt/live/$server/privkey.pem"
RequestHeader set X-Forwarded-Proto "https"
</Macro>
<Macro letsencrypt-challenge $server>
<Directory /etc/apache2/letsencrypt/$server/.well-known/acme-challenge>
Require all granted
</Directory>
RewriteEngine On
RewriteRule /.well-known/acme-challenge/(.*) /etc/apache2/letsencrypt/$server/.well-known/acme-challenge/$1 [L]
</Macro>