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.

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

Now here /ProcessDesigner and /ProcessCore is just a alias/made up name. Currently https://206.189.22.155/ProcessDesigner is showing only partial output (i mean some parts of the page fail to load because of 503 error service unavailable) and the second app at https://206.189.22.155/ProcessCore is also showing no output.(just a white blank screen).

Note: If i add the below mentioned lines to my frontend

acl path-employeeListnew              path_beg -i /
use_backend backend1               if path-employeeListnew

Then in this case the application at https://206.189.22.155/ProcessDesigner works properly and i can see the complete output.But this fix is not a proper fix because now if i hit https://206.189.22.155/ProcessCore i get 404 not found error. The only case when https://206.189.22.155/ProcessCore works is when i use the below configration-

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-employeeListnew              path_beg -i /
    use_backend backend2               if path-employeeListnew

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

    backend backend2
    mode    http

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

    server  backend2 206.189.22.155:5000

Therefore at any given time i am able to map only a single application and not multiple applications. Plz help as i dont think there is anything to change within the application itself rather i believe there is something wrong with my haproxy configuration.

1 Answers1

1

Whilst it's impossible to know for certain based on what you've provided, I'd say the overwhelming likelihood is that, in fact, you do have to change the application, to write out relative URLs that have the correct path information for the location via which they need to be accessed. The fact that some resources don't load when proxied via a sub-path indicates that they are using an absolute path, which isn't correct when the application is accessed via a sub-path.

womble
  • 96,255
  • 29
  • 175
  • 230
  • Then there is nothing with my haproxy config right?Is this the way how you would map applications? – swetha swaminathan Oct 10 '19 at 05:39
  • my main goal here to use the /pathname instead of the portnumber in the url!! – swetha swaminathan Oct 10 '19 at 05:42
  • the /pathname is just an alias used instead of speciying the port number!!.I mean i just made up some random path names like /ProcessDesigner and /ProcessCore .It is not a service/resource that is a part of the application itself.So i dont understand where and what has to be changed in the application itself? – swetha swaminathan Oct 10 '19 at 10:36
  • If you have obfuscated your question such that what you have asked is not representative of what you are actually trying to achieve, then it is unlikely that you will get an answer which is helpful to you. – womble Oct 10 '19 at 21:31