Append prefix to backend

The application listens on 192.168.9.67:8080/JMaster. When you hit this URL , it prompts for login , now the URL changes to
192.168.9.67:8080/JMaster/login. After login , it changes URL back to 192.168.9.67:8080/JMaster as you are logged in .

Now , I have HAPROXY configured on another server and want users to use the Jenkins app by hitting the HAPROXY URL .Likewise I have other systems too , that needs to use a single URL but with prefix switching .
So I have frontend /JMaster configured to redirect calls to actual server.
I use it like this haproxyip/JMaster .

frontend http-in
 bind *:80
 option http-server-close
 option forwardfor
 acl has_jenkins path_beg /JMaster
 use_backend jenkins_server if has_jenkins
 default_backend jenkins_server

backend jenkins_server
 balance roundrobin
 reqrep ^([^\ ]\ /)JMaster[/]?(.) \1\2
 server ws2 192.168.9.67:8080

After hitting the login page , it changes the URL to HAPROXYip/login which is 404 not found

This needs to be tackled from application which I figured out later , The application needs to have context path set to /JMaster , then remove
reqrep ^([^\ ]\ /)JMaster[/]?(.) \1\2
which resolves the issue