• Resolved cshabazian

    (@cshabazian)


    I am using an external IP address via [ redundant link deleted ] which directs traffic to a server I’m running haproxy on. This works just fine to access the wordpress site landing page (main page) via public URL FQDN (Example: https://wp.mywordpress.com), but any other pages it redirects it to the site/home URL which is the internal IP address of the site (Example: http://192.168.1.1). This works fine for me on my home network of course, but I cannot access anything via the public URL. If I change the site/home URL to the external FQDN, then it stops working. There is obviously a setting I need somewhere in WordPress, but I’ve tried using a rewrite with .htaccess, setting the home/site URL to the external address, and it doesn’t work.

    Help or pointers would be very much appreciated!

    My haproxy setup is very simple:

    ########################## FRONTENDS ##########################

    frontend webservers
        bind :80
        bind *:443  ssl crt /etc/letsencrypt/live/mywordpress.com/fullcert.pem
        redirect scheme https code 301 if !{ ssl_fc }
        mode http

    # wp.mywordpress.com
    acl host_wp.mywordpress.com hdr(host) -i wp.mywordpress.com
    use_backend wp.mywordpress.com if host_wp.mywordpress.com

    ########################## BACKENDS ###########################

    # wp.mywordpress.com
    backend wp.mywordpress.com
    server wp.mywordpress.com 192.168.1.1:80 check


    (NOTE: The SSL termination on the haproxy works just fine. I get a secure connection, and the certificate is properly used)

    • This topic was modified 4 months ago by bcworkz. Reason: formatting fixed
    • This topic was modified 4 months ago by Jan Dembowski.

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • davidjason

    (@davidjason)

    Hi there,

    The issue is likely that WordPress needs to recognize the correct URL in wp-options. Try these:

    1. Go to wp-config.php and add:
      define(‘WP_HOME’, ‘https://wp.mywordpress.com’);
      define(‘WP_SITEURL’, ‘https://wp.mywordpress.com’);
    2. Or via database: Update wp_options table:
      siteurl = https://wp.mywordpress.com
      home = https://wp.mywordpress.com
    3. Make sure haproxy is forwarding the Host header correctly. Add to haproxy:
      reqadd X-Forwarded-Proto: https
      reqadd X-Forwarded-Host: wp.mywordpress.com

    This tells WordPress the external URL when accessed through the proxy. Give these a try!

    Thread Starter cshabazian

    (@cshabazian)

    Thanks for the advice. I changed the backend to:

    backend wp.mywordpress.com
    http-request add-header X-Forwarded-Proto https
    http-request add-header X-Forwarded-Host: wp.mywordpress.com
    server wp.mywordpress.com 192.168.1.1:80 check

    And configured the site/home url to https://wp.mywordpress.com but I’m getting too many redirects:
    =====================================

    This page isn’t working

    wp.mywordpress.com redirected you too many times.

    =====================================

    FYI, it DOES now work properly for other links. Example, I click on an entry, and it takes me to it instead of the internal IP address page, so it just seems to be a problem with wp-admin now

    • This reply was modified 4 months ago by cshabazian.
    • This reply was modified 4 months ago by cshabazian.
    • This reply was modified 4 months ago by cshabazian.
    • This reply was modified 4 months ago by cshabazian.
    Thread Starter cshabazian

    (@cshabazian)

    Just to be clear (because I received a moderator message telling me to post in the correct forum), I am using SELF HOSTED WordPress.org. I assume I got that email because of the “representative URL” I have above. I will change it from .com to .org in future posts to clarify.

    • This reply was modified 4 months ago by cshabazian.
    Thread Starter cshabazian

    (@cshabazian)

    Ok, so for anyone who runs across this in the future, the problem was due to the fact that I am terminating SSL on the proxy, and my backend is on port 80. The fix is to add the following (I put it before Database settings, but you should be able to put it anywhere)

    // ** This is because the front end is https and the back end is http ** //
    $_SERVER['HTTPS'] = 'on';
Viewing 4 replies - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.