如何将HAProxyconfiguration为从path中获取后端uri?

我想使用HAProxy作为反向代理,并从path中取回后端主机:

  • http://haproxy/web1/index.html – > http://web1/static/index.html
  • http://haproxy/web2/index.html – > http://web2/static/index.html

后端服务器是dynamic的,不应该被硬编码。 我设法用nginx来实现,但是我无法用HAProxy实现同样的function。

server { listen 80; server_name localhost; location ~ ^/(.*)/(.*) { proxy_pass http://$1/static/$2; } } 

用HAProxy做这个是不是一个好主意,还是应该坚持用NGINX?