Getting SSL/HTTPS Reverse Proxies working on Apache

I just got SSL/HTTPS working on this blog, which wasn’t trivial since I use Apache and a reverse proxy to point the domain to a node server running on a specific port. Phew. I eventually figured out a way to do it after splitting up all my VirtualHosts into their own files and getting an HTTPS error with a mention of the 443 port. Because of that I tried to add another VirtualHost that listens to that particular host, and voilà, it works! Here are my .conf files for reference:

For HTTPS (:443)

<VirtualHost *:443>
  ProxyPreserveHost On
  ProxyRequests Off
  ServerName blog.fabianschultz.com
  ServerAlias blog.fabianschultz.com
  ProxyPass / http://0.0.0.0:1337/
  ProxyPassReverse / http://0.0.0.0:1337/
  SSLEngine On
  SSLProxyEngine On
  SSLCertificateFile /etc/letsencrypt/live/blog.fabianschultz.com/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/blog.fabianschultz.com/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/blog.fabianschultz.com/fullchain.pem
</VirtualHost>

Then redirect all HTTP traffic (:80)

<VirtualHost *:80>
  ServerName blog.fabianschultz.com
  Redirect / https://blog.fabianschultz.com/  
</VirtualHost>

EDIT: Also managed to enable HTTP/2 :raised_hands:. Followed this tutorial to update Apache and then added Protocols h2 http/1.1 to my VirtualHost. It kind of feels like I’m over-engineering this blog, but I’m learning a lot and it’s a little fun, too!

← Fabian Schultz · July 8, 2017