0

So basically I have 2 different applications running on port 5000 and 30000 on a single ubuntu server respectively.Both these application has to be mapped using haproxy.I am using acl path_beg to use a made up pathname(alias) to access these applications instead of using their respective port numbers.

what i have tried so far

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 backend1               if path-employeeList

    acl path-employeeListfinal            path_beg -i /ProcessCore
    use_backend backend2               if path-employeeListfinal

backend backend1
    mode    http

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

    server  backend1  206.189.22.155:30000


backend backend2
    mode    http

    option  httplog
    option  forwardfor
    reqrep  ^([^\ :]+)\ /ProcessCore/?(.*)$  \1\ /\2

    server  backend2 206.189.22.155:5000

Using this configuration i am only able to access the first application at https://206.189.22.155/ProcessDesigner, but when i try to access the second application at https://206.189.22.155/ProcessCore i get a white blank page with no output.Inspecting the page and checking the console shows me "Failed to load resource:the server responded with a status of 503(service unavailable)".

1 Answers1

0

I think You shouldnt open a new question. So see haproxy redirection not working using pathname? and first remove these lines:

    acl path-employeeListnew              path_beg -i /
    use_backend backend1               if path-employeeListnew
EOhm
  • 815
  • 3
  • 7
  • ok i removed those lines....the 1st app is reachable at https://206.189.22.155/ProcessDesigner but the 2nd app at https://206.189.22.155/ProcessCore is just showing a black white page with no output. – Swetha Swaminathan Oct 08 '19 at 18:03
  • i inspected the page in chrome browser and in the console it says "Failed to load resource:the server responded with a status of 503(service unavailable). – Swetha Swaminathan Oct 08 '19 at 18:06
  • ie, backend1 works but backend2 doesnt – Swetha Swaminathan Oct 08 '19 at 18:08
  • ok You need first to fix backend 1 - if you have that working properly its time to check backend 2. so You must get backend1 working without the path-employeeListnew. (possibly it's unavoidable to re-add soemtghing similiar but that is a last resort option then). So if You remove these ACLs, what do You get for App1? Or is it working then? (If App1 is working wothout the amployeeListNew stuff then check ProcessCore in dev console / network-analysis tab and tell the details of the ressources that are failing like wich path requested in that case from server or what) – EOhm Oct 08 '19 at 18:22
  • If i remove the acl path-employeeListnew then https://206.189.22.155/ProcessDesigner is loading (works!) but https://206.189.22.155/ProcessCore is not loading. – Swetha Swaminathan Oct 08 '19 at 18:40
  • in the chrome console it says GET https://206.189.22.155/js/app.fa4c921d.js net::ERR_ABORTED 503 (Service Unavailable) , GET https://206.189.22.155/favicon.ico 503 (Service Unavailable) and finally GET https://206.189.22.155/js/chunk-2d225f08.294ace6b.js net::ERR_ABORTED 503 (Service Unavailable) – Swetha Swaminathan Oct 08 '19 at 18:43
  • Ok. So You should find the place where the Process ore app sends the path to the client. Is it in HTTP headers? Then it is something that the proxy can/should handle with the response headers rewrite. If it is sent within HTML or scripts or such the Backend application is not well-behaving, not properly configured and that should be solved in Backend App Code/Configuration. – EOhm Oct 08 '19 at 19:01
  • Well there is a nother way that would probably work but it is very unpreferrable and not safe mode of operation (in some cases it might not work also depending on the behaviour of the Webbrowser and other code the app executes at client side) so it should be avoided. – EOhm Oct 08 '19 at 19:04
  • update:- now even the 1st application at https://206.189.22.155/ProcessDesigner is not working properly.I mean its a partial output.I see some parts of my application like the tile "Flowchart Maker" but the page is not completely loading. In the browser console it says Uncaught ReferenceError: App is not defined at ProcessDesigner:440 along with alot of service unavailable 503 errors. – Swetha Swaminathan Oct 09 '19 at 06:22
  • if i add the acl path-employeeListnew path_beg -i / stuff then the 1st app at https://206.189.22.155/ProcessDesigner works and loads completely and doesn't show these errors.Both the problem now is when i add the acl path-employeeListnew path_beg -i / stuff the second application at https://206.189.22.155/ProcessCore is showing 404 not found!! – Swetha Swaminathan Oct 09 '19 at 06:45
  • If i remove the acl path-employeeListnew path_beg -i / stuff the the second app at https://206.189.22.155/ProcessCore doesnt show 404 error but there is simply no output(just a blank white screen).chrome console shows a lot service unavailable 503 errors in this case. – Swetha Swaminathan Oct 09 '19 at 06:50
  • Yes exactly that are my questions for. Check for the Ressourcen requested that get 503 and check from Wich part of app an/or in which part of response the URIs of the ressources are sent to the client – EOhm Oct 09 '19 at 06:53
  • ok i just checked the server.js file of the node.js app and i found these lines – Swetha Swaminathan Oct 09 '19 at 09:42
  • const base_url = 'http://localhost:8080/api/'; const static_dir = '/home/vignesh/page-core-devbranch/dist'; const assets_dir = path.join(__dirname + '/server/assets/'); const tools_dir = path.join(__dirname + '/server/tools/'); const index_file = path.join(static_dir + '/index.html'); /* listen */ app.listen(5000); – Swetha Swaminathan Oct 09 '19 at 09:43
  • base_url is the one which has to be changed? – Swetha Swaminathan Oct 09 '19 at 09:44
  • I cannot tell You exactly wether this solves all problems. Or it even looks quite unrelated to the information I got from You till now (it would only apply for ressources that the client in effect tries to download from localhost:8080/api I would expect and should not cause 404 or 503 errors as last long as nothing else runs on Your port 8080). From which URL are the ressources loaded or tried to be loaded that return 404 or 503? – EOhm Oct 09 '19 at 20:52
  • Generally such variable is not good in code it includes hostname and port but no protocol. This cannot be cleanly used to refer to internal code not itself to refer to external code (without the protocol). A usable variable would contain protocol hostname port and base path in the URL and could be rewritten to more polite path only containing base path. – EOhm Oct 09 '19 at 21:01