access webinterface/vnc via apache reverse proxy / load balancer, novnc ws connection failing

jannik.rosendahl

New Member
Apr 4, 2023
1
0
1
Hello,
I have 3 nodes (alpha, beta, gamma) that I am trying to access via a reverse-proxy with a balancer, the idea being that if one node goes down, the balancer will select another node automatically. I am using apache2 as the reverse proxy.
I got the web-interface working, but when using the console, I am getting a "Failed to connect to server" error.
The js console shows 2 errors:
Failed when connecting: Connection closed (code: 1006)
WebSocket connection to 'wss://revproxy.domain.com/api2/json/nodes/domain-alpha/qemu/1007/vncwebsocket?port=5900&vncticket=blabla' failed:

The apache log shows the following when trying to connect to vnc:
[Tue Apr 04 11:14:45.596190 2023] [proxy:error] [pid 13908:tid 140486551492352] [client myip:51628] AH00898: DNS lookup failure for: balancer: returned by /api2/json/nodes/alpha/qemu/1007/vncwebsocket

I suspect i am not proxy-passing the Websocket connection the right way.
The config from this thread seems to solve a part of the problem, but i cannot get it to work with a load balancer.
ping

I should have all the necessary apache mods enabled (proxy*, ssl, lbmethod_byrequests, rewrite).
My apache config:
XML:
<VirtualHost *:80>
    ServerName revproxy.domain.com
    
    Redirect permanent "/" "https://revproxy.domain.com/"
</VirtualHost>

<VirtualHost *:443>
    ServerName revproxy.domain.com
    
    Header add Set-Cookie "ROUTEID=.%{BALANCER_WORKER_ROUTE}e; path=/" env=BALANCER_ROUTE_CHANGED
    <Proxy "balancer://revproxy">
        BalancerMember "https://alpha.domain.com:8006" route=1
        BalancerMember  "https://beta.domain.com:8006" route=2
        BalancerMember "https://gamma.domain.com:8006" route=3
        ProxySet lbmethod=byrequests stickysession=ROUTEID
    </Proxy>
    <Proxy "balancer://revproxy-ws">
                BalancerMember "wss://alpha.domain.com:8006" route=1
                BalancerMember  "wss://beta.domain.com:8006" route=2
                BalancerMember "wss://gamma.domain.com:8006" route=3
        ProxySet lbmethod=byrequests stickysession=ROUTEID
    </Proxy>

    SSLProxyEngine on
    ProxyPass            "/"    "balancer://revproxy/"
    ProxyPassReverse    "/"    "balancer://revproxy/"

    <LocationMatch ^/(api2/json/nodes/[^\/]+/[^\/]+/[^\/]+/vncwebsocket.*)$>
        ProxyPass wss://balancer://revproxy-ws/$1 retry=0
    </LocationMatch>

    <Location /websockify>
        ProxyPass balancer://revproxy-ws
        ProxyPassReverse balancer://revproxy-ws
    </Location>

    SSLEngine on
    SSLCertificateFile "/root/domain.crt"
    SSLCertificateKeyFile "/root/domain.key"
</VirtualHost>
 
1705419638787.png

hi,
i am trying to install proxmox and access it through cloudflare, but error occur after logged in,
how to solve this error?

thank you.