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

    WordPress behind HAProxy

    Scheduled Pinned Locked Moved Cache/Proxy
    8 Posts 5 Posters 2.8k 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.
    • M
      mr-elamin2
      last edited by

      Hi there,
      I have a containerized WordPress server running multiple sites with Traefik, PHPMyAdmin, MySQL DB, and Redis for the cache.
      I use only port 80 without SSL in the backend and everything works behind the Pfsense perfectly.
      I use SSL Offloading in the HAProxy on my Pfsense but when I try to reach https://mysite.com/wp-admin the page never loads correctly and I can not send login data as well :(
      please see the attached screenshots.
      what shall I do on my firewall to make my sites work correctly from the Frontend?

      infront of the firewall.png
      behind the firewall.png

      I appreciate any answer :)
      Thanks alot.

      V 1 Reply Last reply Reply Quote 0
      • V
        viragomann @mr-elamin2
        last edited by

        @mr-elamin2
        Did you create a http to https redirect rule in the frontend?

        M 1 Reply Last reply Reply Quote 0
        • M
          mr-elamin2 @viragomann
          last edited by

          @viragomann
          Yes, all requests on port 80 will get redirected to port 443.
          I have other sites and everything work fine except WordPress.!

          V 1 Reply Last reply Reply Quote 0
          • V
            viragomann @mr-elamin2
            last edited by

            @mr-elamin2
            Seems that the CSS cannot be fetched properly.

            I don't use WP actually behind HAproxy, so I'm not experienced with it.
            But you can use the debugging mode in the browser to find out, what's going wrong.

            1 Reply Last reply Reply Quote 0
            • M
              mr-elamin2
              last edited by

              Hi all,

              I have got the solution:

              adding the bellow code to the wp-config.php file right after <?php in the file has solved my problem.

              <?php

              // force SSL
              $_SERVER['HTTPS']='on';

              define('WP_HOME','http://mysite.com');
              define('WP_SITEURL','http://mysite.com');

              Thanks all :)

              B G I 3 Replies Last reply Reply Quote 0
              • B
                brauliock @mr-elamin2
                last edited by

                @mr-elamin2 Thanks a lot! Been troubleshooting this issue for more than a day but finnaly got it sort out with your method

                1 Reply Last reply Reply Quote 0
                • G
                  gcjh01 @mr-elamin2
                  last edited by

                  @mr-elamin2 said in WordPress behind HAProxy:

                  // force SSL
                  $_SERVER['HTTPS']='on';

                  define('WP_HOME','http://mysite.com');
                  define('WP_SITEURL','http://mysite.com');

                  Thank you! This was a lifesaver!

                  1 Reply Last reply Reply Quote 0
                  • I
                    ihavealegohead @mr-elamin2
                    last edited by

                    @mr-elamin2 said in WordPress behind HAProxy:

                    $_SERVER['HTTPS']='on';

                    define('WP_HOME','http://mysite.com');
                    define('WP_SITEURL','http://mysite.com');

                    Failed for me, but for WP 6.7.2, I added this to the top of the wp-config.php to make it work:

                    define('FORCE_SSL_ADMIN', false);
                    if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
                    $_SERVER['HTTPS']='on';

                    define('WP_HOME','http://sitename.com');
                    define('WP_SITEURL','http://sitename.com');

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