I know i have asked this before but i dint get any answers for the question.So basically i have a node js app running on port 5000.I have successfully redirected this to port 8080 using the following haproxy configuration-
frontend http-in
mode http
bind *:8080
acl path-employeeList path_beg -i /
use_backend employeeList-backend if path-employeeList
backend employeeList-backend
mode http
option httplog
option forwardfor
server appserver1 206.189.22.155:5000
I can now access my app now at http://206.189.22.155:8080. But now in this url, instead of using the portnumber (8080) ,i want to access my app using a made up path name like /ProcessDesigner.ie,the app should be reachable at http://206.189.22.155/ProcessDesigner.
What i have tried so far
frontend http-in
mode http
bind *:8080
acl path-page-designer path_beg -i /ProcessDesigner
use_backend page-designer-backend if path-page-designer
backend page-designer-backend
mode http
option httplog
option forwardfor
http-request set-path /ProcessDesigner
server appserver1 206.189.22.155:5000
when I hit http://206.189.22.155/ProcessDesigner it says the site cannot be reached. I am doing this so that the user doesn't have to remember the port number and can just access using the pathname. So for this how should i change my configuration.Plz help by showing an example using my config!!
UPDATE using http to https redirection(80->443) and reqrep in the backend.
frontend http-in
mode http
bind *:80
bind *:443 ssl crt /etc/ssl/private/mydomain.pem
http-request redirect scheme https code 301 if !{ ssl_fc }
acl path-employeeList path_beg -i /ProcessDesigner
use_backend employeeList-backend if path-employeeList
backend employeeList-backend
mode http
option httplog
option forwardfor
reqrep ^([^\ :]+)\ /ProcessDesigner/?(.*)$ \1\ /\2
server appserver1 206.189.22.155:5000
Now with this updated configuration when i hit https://206.189.22.155/ it says
503 service unavailable ( No server is available to handle this request.) and when i hit https://206.189.22.155/ProcessDesigner I dont see any errors anymore but just a blank white page.Although I can see the tab name "sample" which indicates or atleast seems as if it has reached the application , there is no output but just a blank white screen.
Best Answer
What I can see in Your "what I have tried" example: You still bind to Port 8080 instead of just 80 so the site cannot be reached.
In addition the following line is probably not what You want.
It causes the request always to the backend to be always /ProcessDesigner, possibly with a query string appended.
I can imagine You need a line like the following instead to strip the /ProcessDesigner from the URI sent to backend:
But keep in mind the application should be properly designed to only deliver relative paths for application-local ressources within the response body (or need at least to be configurable that You can set the base path for such paths).
And it might be necessary to also rewrite the response Headers like location for redirects and set-cookie for cookies (further well-known but less common headers where this would apply are uri and content-location) as ideally the application does not need to know the URL prefix the client used for access but the cookie must be marked with the path the browser accesses the site (the
rsprep
exists to do such things on the response headers).