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

    SSL certs handling and HAproxy

    Scheduled Pinned Locked Moved General pfSense Questions
    136 Posts 3 Posters 25.3k 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.
    • L
      lewis @kiokoman
      last edited by

      @kiokoman

      First, I've been wondering if I'm coming across a bug again.
      Second, I've been considering starting all over again but I've tried so many things that at this point, I think I'll make a mistake in the config.
      I will give it a try now however.

      1 Reply Last reply Reply Quote 0
      • L
        lewis
        last edited by lewis

        I tore it all down and rebuilt it.
        There's definitely a bug alright. Doing that, now I see http heartbeat finally.
        The ssl cert checks out as the one in acme on pfsense.

        Incoming connections to the web server are now http as they should be but, public connections are now getting;

        The page isn’t redirecting properly

        I know http works fine because I've tested it from other servers and the web server responds as it should.

        I find it a little hard to believe that if this is a bug that it's not well known?

        stephenw10S 1 Reply Last reply Reply Quote 0
        • L
          lewis
          last edited by lewis

          tcpdump on the web server;

          12:32:54.007855 ens18 In  IP _gateway.28554 > r9ty01.phx.loc.http: Flags [S], seq 3274415560, win 65228, options [mss 1460,nop,wscale 7,sackOK,TS val 511869013 ecr 0], length 0
          12:32:54.008023 ens18 Out IP r9ty01.phx.loc.http > _gateway.28554: Flags [S.], seq 266390645, ack 3274415561, win 65160, options [mss 1460,sackOK,TS val 2446701473 ecr 511869013,nop,wscale 7], length 0
          
          
          

          The redirection error is odd since it's not happening from any other internal client.

          1 Reply Last reply Reply Quote 0
          • L
            lewis
            last edited by lewis

            I checked using curl and a windows machine on the lan, all reach the web server as they should.
            Only public connections are getting the 'redirect' error.

             - - [02/Jan/2024:12:55:32 -0700] "GET / HTTP/1.1" 301 4690 197049 196471 "-" "Mozilla/5.0 (Windows NT 10.0; rv:109.0) Gecko/20100101 Firefox/115.0"
            
            
            1 Reply Last reply Reply Quote 0
            • L
              lewis
              last edited by

              Just for giggles, I changed haproxy to point to varnish and that is now working too.
              Meaning, it's sending the traffic to the web server using http.

              At this point, all I can think of is that there is something in the headers being sent from haproxy which is causing this constant 301.

              1 Reply Last reply Reply Quote 0
              • stephenw10S
                stephenw10 Netgate Administrator @lewis
                last edited by

                @lewis said in SSL certs handling and HAproxy:

                The page isn’t redirecting properly

                How exactly are you testing when you see that? From some external IP? Using http?

                Is HAProxy configured to redirect http to https?

                L 1 Reply Last reply Reply Quote 0
                • L
                  lewis @stephenw10
                  last edited by

                  I guess you missed some of my comments.

                  Is HAProxy configured to redirect http to https?
                  How exactly are you testing when you see that? From some external IP? Using http?

                  The traffic is finally hitting the server as http so that part is solved.

                  I've tested from internal (LAN) clients using curl and firefox to http since the firewall is handling the ssl cert.
                  Internally, all is good, web pages are being served up using http.
                  Externally or public, everything gets a 301.

                  From external connections, I'm connecting to https and can see the traffic being sent from haproxy to http.

                  kiokomanK 1 Reply Last reply Reply Quote 0
                  • kiokomanK
                    kiokoman LAYER 8 @lewis
                    last edited by

                    @lewis
                    what are you running on the server? apache2 ?
                    that's usually a misconfiguration in the web server, maybe a redirection on the config that you don't need anymore

                    ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                    Please do not use chat/PM to ask for help
                    we must focus on silencing this @guest character. we must make up lies and alter the copyrights !
                    Don't forget to Upvote with the 👍 button for any post you find to be helpful.

                    1 Reply Last reply Reply Quote 0
                    • L
                      lewis
                      last edited by

                      I checked the incoming headers and for some reason, http is still being forwarded to https so I think the problem is with the web server at this point.
                      It's odd because there is no forwarding configured, at all on the web server so I'll spend some time on this and see what I can discover.

                      It's darn close now that I've rebuilt the haproxy config.

                      kiokomanK 1 Reply Last reply Reply Quote 0
                      • kiokomanK
                        kiokoman LAYER 8 @lewis
                        last edited by

                        @lewis
                        that error is usually from a redirect in the web server, haproxy try to comunicate with the web server via http but the server answer back via https but since haproxy is expecting HTTP traffic, it keeps resending the same request, resulting in a redirect loop

                        nginx could have something like -> return 301 https://$server_name$request_uri;
                        apache2 could have something like -> RewriteEngine / RewriteCond / RewriteRule

                        ̿' ̿'\̵͇̿̿\з=(◕_◕)=ε/̵͇̿̿/'̿'̿ ̿
                        Please do not use chat/PM to ask for help
                        we must focus on silencing this @guest character. we must make up lies and alter the copyrights !
                        Don't forget to Upvote with the 👍 button for any post you find to be helpful.

                        1 Reply Last reply Reply Quote 0
                        • L
                          lewis
                          last edited by lewis

                          So what seems to be happening is that because the site was built with all urls being https, no matter if I hit it using http, the urls are all htps so the browser keeps getting https.

                          I dumped the application db, edited all the links to be http and it 'sort of' works.
                          I can fix the problems but it's not going to solve the main problem which is the sites cannot all be rebuilt to be http.
                          So, all this for nothing ti seems unless there's some way to get https pages working with haproxy as well.

                          1 Reply Last reply Reply Quote 0
                          • stephenw10S
                            stephenw10 Netgate Administrator
                            last edited by

                            Hmm, if you only see that when connecting externally though that's only when the connection is going through HAProxy.

                            What I expected would be a redirect in the HAProxy front end. That should only ever be for http to https for client connections but it would be possible to have ot set the other way around accidentally.

                            1 Reply Last reply Reply Quote 0
                            • stephenw10S
                              stephenw10 Netgate Administrator
                              last edited by

                              HAProxy will work fine using https to the backends if you need it to. I have no idea if you can add Varnish to that though.

                              L 1 Reply Last reply Reply Quote 1
                              • L
                                lewis
                                last edited by

                                Well, I showed all of my configuration and I can see haproxy sending to http.
                                Even after changing all of the urls to http, the page is still showing up broken to public clients but perfectly to internal.

                                1 Reply Last reply Reply Quote 0
                                • L
                                  lewis @stephenw10
                                  last edited by

                                  @stephenw10 said in SSL certs handling and HAproxy:

                                  HAProxy will work fine using https to the backends if you need it to. I have no idea if you can add Varnish to that though.

                                  Right, that was the entire goal so if I can't do that, then this is all moot.

                                  1 Reply Last reply Reply Quote 0
                                  • stephenw10S
                                    stephenw10 Netgate Administrator
                                    last edited by

                                    Well if the backend servers can only respond correctly to https connections then Varnish needs to use https to connect to them.

                                    You might try using a very simple site that you know works fine with http as a test until you have the other parts working.

                                    L 1 Reply Last reply Reply Quote 0
                                    • L
                                      lewis @stephenw10
                                      last edited by

                                      You might try using a very simple site that you know works fine with http as a test until you have the other parts working.

                                      That's what this site was, for testing.
                                      Other than this post, I can't find much more information so I guess I don't get to set this up the way I need it.

                                      1 Reply Last reply Reply Quote 0
                                      • stephenw10S
                                        stephenw10 Netgate Administrator
                                        last edited by

                                        By very simple I mean just an index page. Nothing with anything linking to https.

                                        L 1 Reply Last reply Reply Quote 0
                                        • L
                                          lewis @stephenw10
                                          last edited by

                                          @stephenw10 said in SSL certs handling and HAproxy:

                                          By very simple I mean just an index page. Nothing with anything linking to https.

                                          Yes, I already proved to myself that haproxy is sending http now but the site is built in https.
                                          I dumped the db, renamed all of the https urls to http and it worked fine other than some small things I'd have to fix.

                                          The problem is, I cannot do that to all of the apps that would be in play here, it's simply too much work.
                                          The only other option I have is to not use haproxy on pfsense, but use acme only to have that centralized part I wanted.

                                          Setups could be a proxy/varnish on a server. Not sure if pfsense can send pure http after acme to the LAN.

                                          1 Reply Last reply Reply Quote 0
                                          • stephenw10S
                                            stephenw10 Netgate Administrator
                                            last edited by

                                            I'd be surprised if Varnish can't also use https. As long as the front and backend sessions are terminated there it can still see and cache all the content.

                                            But, yes, if you're running Varnish on some separate server then it might be easier to do it all there.

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