Haproxy url rewrite and redirect using ssl


#1

My requirement is to hit multiple urls in the same context path through haproxy
1)https:(slash slash) mydomain/context/path1 (backend servers 1)
2)https://mydomain/context/path2 ((backend servers 2)
Both the paths will use different backend servers
Now all the css and jpegs for that path (https: mydomain/context) should be served from same backend servers.

Added to that i want to redirect urls to backends based on some custom path
So i want the user to give https://mydomain/context/<custom_path> . I want the backend to strip <custom_path> before sending request to backend servers with all the css/jpegs etc … gettin served from same backend.

Please note I am doing: . SSL/TLS bridging or re-encryption: (In this mode, HAProxy decipher the traffic on the client side and re-encrypt it on the server side)

The way i tried to do it was i tried to achieve this is given below.I tried to strip the ENV1 in the backend while directing it to the servers. Inserted a cookie in the hdr .
On subsequent request with cookie all requests should be ideally routed to the same backend which will force css and jpegs also to same backend . This does not work at all . Help is appreciated

frontend HTTP_PROXY
bind *:443 ssl crt /etc/haproxy/cert.d/key1.pem
mode http
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]

acl SEARCHP_PATH path_beg -i /dsdataserver-console/ENV1
use_backend SEARCHP_BACKEND if SEARCHP_PATH

acl is_searchplugin_cookie hdr_sub(cookie) DSIS_C_NODE=SEARCH
use_backend SEARCHP_BACKEND if is_searchplugin_cookie

backend SEARCHP_BACKEND
mode http
balance source
cookie DSIS_C_NODE insert
reqrep ^([^\ ]\ /)web1[/]?(.) \1\2
server app34 34.36.74.74:8443 cookie SEARCH ssl verify required ca-file /etc/haproxy/cert.d/key1.pem check