How to set up Apache2 to let Let's Encrypt certbot find HA VM?

Thanks aceindy. The differences I noted were that you have ProxyPreserveHost on, which didn’t affect my results, and the 3 lines dealing with Rewriting, which seems to be the operative factor. You also include the Let’s Encrypt options file, which doesn’t seem to affect the results.

You left out the websocket directives and I noticed that removing them from my setup also worked. They don’t seem to be necessary so far.

In short, it’s the rewriting rules that seem to be the important factor.

Thanks!

Here’s my complete apache2 conf file:

<VirtualHost *:80>
    ServerAdmin <my e-mail>
    ServerName ha.<my domain>
    redirect permanent / https://ha.<my domain>/
</VirtualHost>

<VirtualHost *:443>
    # SSL
    SSLEngine on
    SSLProxyEngine on
    SSLCertificateFile /etc/letsencrypt/live/<my domain>/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/<my domain>/privkey.pem
    # Basics
    ServerName ha.<my domain>
    # Proxy
    ProxyPreserveHost On
    ProxyRequests off
    SSLProxyEngine On
    ProxyPass / http://192.168.1.38:8123/
    ProxyPassReverse / http://192.168.1.38:8123/
    RewriteEngine on
    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*) ws://192.168.1.38:8123/$1 [P,L]
#    Include /etc/letsencrypt/options-ssl-apache.conf
#    ProxyPass /api/websocket wss://192.168.1.38:8123/api/websocket
#    ProxyPassReverse /api/websocket wss://192.168.1.38:8123/api/websocket
</VirtualHost>