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

    HTTPS redirection and Haproxy little problem

    Scheduled Pinned Locked Moved Cache/Proxy
    4 Posts 2 Posters 2.0k 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.
    • E
      execcr
      last edited by

      Hello,
      i have a problem with haproxy https redirection.
      I have this configuration:
      2 frontend on haproxy:
      1 for http port 80 with 2 rules: the first is for letsencrypt certificate folder ( Path starts with: no /.well-known/acme-challenge/ redirect to certificate challenge forlder) the second redirect all the other request Path starts with: yes /.well-known/acme-challenge/ to a backend with a dummy server and a backend passthru rule redirect scheme https code 301
      1 for https with 2 acl rules for 2 backend server.

      The aim is to redirect all http://server1.domain.com and http://server2.domain.com to HTTPS.
      The problem is that: if i wrote http://server1.domain.com on chrome it works the first time, i get redirect to https and i get the login page of my webservice. Then i write my credential but the login page then load the HTTP url and not the HTTPS one throwing a 503 error page. I didn't have this problem when i used apache2 as reverse proxy for this 2 servers.
      Any hint?

      1 Reply Last reply Reply Quote 0
      • D
        doktornotor Banned
        last edited by

        Try something like

        
        http-request set-header X-Forwarded-Port %[dst_port]
        http-request add-header X-Forwarded-Proto https if { ssl_fc }
        
        

        on the backend.

        Might also need

        
        acl secure dst_port eq 443
        rsprep ^Set-Cookie:\ (.*) Set-Cookie:\ \1;\ Secure if secure
        
        

        on the frontend.

        1 Reply Last reply Reply Quote 0
        • E
          execcr
          last edited by

          Thank you for the hint.
          i've configured haproxy via webgui, is a problem to edit directly the conf files to add that lines?

          1 Reply Last reply Reply Quote 0
          • D
            doktornotor Banned
            last edited by

            Do NOT edit the config files, use the GUI.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.