Convert Small Nginx Config to HAProxy

Please, I need some help converting this NGINX config to HAProxy. Essentially, the config extracts IP address, the port, and the relative path from the overall URL and dynamically redirect to this extracted server. One thing that might not be obvious from this config is that it also does websocket. This explains some of the weird settings you would see (e.g. upgrade).

Any help would be much appreciated.

server {
listen 80;

location ~ ^/forward/([^/]+)/([^/]+)/(.*)$ {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_pass http://$1:$2/$3;
}

}

You can’t do this with haproxy. Haproxy has fixed backend servers.