Thanks @Jon, I was close but couldn’t have made it work without your help, or at least not without losing a few extra hours! So thank you very much!
Here’s the final solution, if it helps anyone else:
<VirtualHost *:80>
# HTTP -> HTTPS
ServerName n8n.domain.com
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:443>
ServerName n8n.domain.com
SSLEngine On
SSLProxyEngine On
ProxyRequests Off
ProxyPreserveHost On
SSLCertificateFile /etc/apache2/certs/2023_wildcard.domain.crt
SSLCertificateKeyFile /etc/apache2/certs/2023_wildcard.domain.key
SSLCertificateChainFile /etc/apache2/certs/2023_wildcard.domain_inter.crt
TimeOut 600
KeepAliveTimeout 600
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
<Proxy *>
Require all granted
</Proxy>
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://localhost:5678/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://localhost:5678/$1 [P,L]
ProxyPassReverse / http://n8n.domain.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Have a nice day!
Kind regards,