URL redirection issue

Hi Team,

I am facing issue in URL redirection. Need your help and suggestion.

Using : HA-Proxy version 2.0.4 2019/08/06 - https://haproxy.org/

Created HTTP & HTTPS Group.

When user hit URL “website.in”.The default website.in will go the default http & https group.

When user hit below mentioned URL.We have configured acl for below mentioned domain to point to specific backend server.

Till now everything is working fine. We have requirement from development Team.

When user hit http://abc.website.in this need to be redirected to https://abc.website.in/service. – We have configured ACL is working fine.

When user hit https://abc.website.in this need to be redirected to https://abc.website.in/service – When we configure ACL this is going to default backend not going to specific backend server.

frontend port80
  acl https ssl_fc
  http-request redirect location https://abc.website.in/service code 302 unless https
  # ...or 301(permanent) or 303(new GET request), personally I'd go with 303 because it instructs
  # the browser to perform a GET request. APIs don't work with redirects so if you've already broken
  # things, might as well go full in. :)
  # It seems you're not serving non-TLS content, so you don't need a server here.

frontend port443
  http-request set-var(txn.txnpath) path
  http-request set-var(txn.txnhost) hdr(host)
  # ↑↑ Captures stuff in variables used in the transactions back and forth ↑↑
  acl xyz.website.in var(txn.txnhost) -m str -i xyz.website.in
  acl abc.website.in var(txn.txnhost) -m str -i abc.website.in
  # ↑↑ A default backend is only needed if you're going to serve content on a wildcard address ↑↑
  # (anything else that you didn't specify beforehand), so having this is a restriction on
  # where (as in location) can content be requested from. If it were "-m end -i website.in" you'd
  # accept everything not "xyz." with a simple "*" CNAME to your main [sub]domain.
  acl path-is-correct var(txn.txnpath) -m beg -i /service
  http-request set-path /service/%[path] if abc.website.in !path-is-correct
  # ↑↑ Might not work if your web server needs to have trailing "/" ↑↑
  # OK: .../service/index.html .../service/image.svg .../service/[hiddenvoodoo] NOT OK: .../service
  use_backend xyz.website.in:443 if xyz.website.in
  use_backend abc.website.in:443 if abc.website.in

backend xyz.website.in:443

backend abc.website.in:443

I think this might be it. You left a lot of stuff out so I’m filling out blank as best and as generically as I can. I’m a newbie too, so you might be best if you wait for a second opinion though. Good luck! :slight_smile:

Thanks for your suggestion.