create application paths with haproxy -


i have server running multiple web apps on different ports without root application path. can access them by, http://myserver:8001, http://myserver:8002, etc , access them via haproxy http://myserver/app1, http://myserver/app2, etc

i found multiple links using reqrep not make work. here last attempt before gave up:

frontend http-in   option forwardfor   bind *:80   acl is-app1 path_beg /app1   use_backend app1 if is-app1   acl is-app2 path_beg /app2   use_backend app2 if is-app2  backend app1   reqrep ^location:\ /app1/?(.*)     location:\ /\1   rsprep ^location:\ (.*)     location:\ /app1/\1   server localhost 127.0.0.1:8001  backend app2   reqrep ^location:\ /app2/?(.*)     location:\ /\1   rsprep ^location:\ (.*)     location:\ /app2/\1   server localhost 127.0.0.1:8002 

from examples saw, expected single line enough (no need rsprep), can't make work.

reqrep ^([^\ :]*)\ /app1/?(.*)     \1\ /\2 

give try - may have modify little suit requirements.

frontend    http-in     bind        *:80     mode        http     option      httplog     option      dontlognull     option      forwardfor      # if "/app1"     use_backend app1 if { path_beg /app1/ }      # if "/app2"     use_backend app2 if { path_beg /app2/ }  backend     app1     reqrep      ^([^\ :]*)\ /app1/(.*) \1\ /\2     option      forwardfor     server      localhost 127.0.0.1:8001  backend     app2     reqrep      ^([^\ :]*)\ /app2/(.*) \1\ /\2     option      forwardfor     server      localhost 127.0.0.1:8002 

Comments