HAProxy and HTTP 301 redirection

  • Hi experts,

    I have a question about HTTP redirection using HAProxy and I didn't found anything here or on the web.

    For an incoming request to "http://www.example.com/test", I want to permanently redirect to "https://example.com/test" .
    So there are two things in here

    a) removing anything under the SLD
    b) using https if not originally requested

    I tried the following frontend configuration, but this does not work.

    ACL: Name:"rule1", Expression:"Host ends with:", Not:"no", Value:"example.com"
    Actions: Action:"http-request redirect", rule:"location https://example.com code 301", Condition acl names:"rule1"

    Can anyone help me? Appreciate your feedback!

Log in to reply