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

WordPress behind HAProxy

Cache/Proxy
5
8
2.7k
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 Jun 29, 2023, 2:48 PM

    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?

    login-to-view
    login-to-view

    I appreciate any answer :)
    Thanks alot.

    V 1 Reply Last reply Jun 29, 2023, 4:10 PM Reply Quote 0
    • V
      viragomann @mr-elamin2
      last edited by Jun 29, 2023, 4:10 PM

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

      M 1 Reply Last reply Jun 29, 2023, 4:49 PM Reply Quote 0
      • M
        mr-elamin2 @viragomann
        last edited by Jun 29, 2023, 4:49 PM

        @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 Jun 29, 2023, 5:36 PM Reply Quote 0
        • V
          viragomann @mr-elamin2
          last edited by Jun 29, 2023, 5:36 PM

          @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 Jun 30, 2023, 10:54 AM

            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 Dec 21, 2023, 11:04 AM Reply Quote 0
            • B
              brauliock @mr-elamin2
              last edited by Dec 21, 2023, 11:04 AM

              @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 Feb 8, 2024, 6:33 PM

                @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 Mar 2, 2025, 7:48 PM

                  @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.