Hey @chizuoka,
I would probably not take advice from ChatGPT on configuration, It is good but you need to also make sure you know what the settings are doing and check that the options provided are current in the documentation and not legacy settings.
Looking at your example have you tried something like the below?
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName n8n.example.com
# Rewrite rules to handle WebSocket connections
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://192.168.0.45:5678/$1 [P,L]
# Rewrite rule for other HTTP requests
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://192.168.0.45:5678/$1 [P,L]
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName n8n.example.com
# Rewrite rules to handle WebSocket connections
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /(.*) ws://192.168.0.45:5678/$1 [P,L]
# Rewrite rule for other HTTP requests
RewriteCond %{HTTP:Upgrade} !=websocket [NC]
RewriteRule /(.*) http://192.168.0.45:5678/$1 [P,L]
</VirtualHost>
</IfModule>