Apache config to Traefik - is this possible?

Hello, I am wondering if the following code snippet from apache is usable in traefik aswell?

The later parts will be easy with the redirect regex middleware. (I think)
But wats with the top Conditions? They check some header Values and if they are set, the rule is applied.
I dont know how to realise this one.

# cat /etc/apache2/sites-available/000-default.conf
<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                RewriteEngine on
                RewriteCond %{HTTP:Upgrade} websocket [NC]
                RewriteCond %{HTTP:Connection} upgrade [NC]
                RewriteRule /(.*) wss://<ip>:<port>/$1 [P,L]

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

                <Location />
                        ProxyPass https://<ip>:<port>/
                        ProxyPassReverse https://<ip>:<port>/
                </Location>
   
                <Location /websockify>
                        ProxyPass ws://<ip>:<port>
                        ProxyPassReverse ws://<ip>:<port>
                </Location>
        </VirtualHost>
</IfModule>

It should be possible with router and middleware.

You could try ChatGPT to translate Apache config to Traefik v2 as a starting point.