Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    HAProxy URL redirect

    Scheduled Pinned Locked Moved Cache/Proxy
    4 Posts 2 Posters 7.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • X
      xternaal
      last edited by

      Hi there,
      I have pfsense haproxy setup correctly and working with acme certs.
      It successfully proxies from say https://service.contoso.com to 192.168.1.5:5000.

      I was wondering how I can setup a http/https redirect in haproxy that redirects or rewrites the url to add the internal DNS suffix when accessing the sites from inside the network. i.e so I can just type "service/" into the url bar and it will convert to https://service.contoso.com (where contoso.com comes from the dhcp search domains).

      The reason for this is internally if i just want to quickly access a site and type "service/" (the '/' stops chrome/firefox from undertaking a search on the term) it throws a ssh certificate error because it doesn't include the wildcard *.contoso.com certificate that haproxy and acme cert have created.

      P 1 Reply Last reply Reply Quote 0
      • P
        PiBa @xternaal
        last edited by

        @xternaal said in HAProxy URL redirect:

        ssh certificate error

        perhaps you mean SSL ? But anyhow, if you are requesting 'https://service/' and haproxy does not have a certificate matching that domain that the browser trusts, then there is no way to send a http-redirect on HTTP-layer7 if the SSL connection on layer6 did not yet shake hands successfully.. Only after clicking through the certificate warning you will be able to send the HTTP GET request, and get a HTTP redirect back to the desired domain...

        If you are requesting http://service/ then it is of-course possible to redirect that to https://service.contoso.com/ .. But im guessing you want the other initial https request scenario to work..?.

        1 Reply Last reply Reply Quote 0
        • X
          xternaal
          last edited by

          Thanks for your response. How would i go about doing the http redirect. That would be good enough

          Cheers

          P 1 Reply Last reply Reply Quote 0
          • P
            PiBa @xternaal
            last edited by

            @xternaal
            Add a acl X that checks 'host matches: service'
            Then add a action that will perform a 'http-request redirect' for fmt: 'location https://service.contoso.com' when the acl X matches.

            1 Reply Last reply Reply Quote 1
            • N nasheayahu referenced this topic on
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.