0

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.

1 Answer 1

0

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.

http-request set-path /ProcessDesigner 

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:

reqrep ^([^\ :]+)\ /ProcessDesigner/?(.*)$ \1\ /\2 

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).

14
  • /ProcessDesigner is just a made up name.Its like an alias that i want to use to reach my app without having to specify the port number 8080 Commented Oct 8, 2019 at 5:33
  • and also where exactly should i add the line reqrep ^([^\ :]+)\ /ProcessDesigner/?(.*)$ \1\ /\2 Commented Oct 8, 2019 at 5:57
  • Yes I understand. So did You try with my suggestions? So changing listening port, removing the line I told You, possibly add the other line instead? I suggest exchanging the reqrep line for the http-request set-path line. With the result one can check which further steps are required to make it work, if any. Commented Oct 8, 2019 at 6:01
  • hi i tried what you said...I have posted an update section in my question.Can you please check the same Commented Oct 8, 2019 at 7:32
  • @SwethaSwaminathan yes I think some more work is needed then. can you please check from browser developer console what is going wrong? I cannot say this way I would need to know exactl design of the webapp. You will probably see at least one failing load in developer console network monitoring tab. Commented Oct 8, 2019 at 8:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.