• Resolved mirky007

    (@mirky007)


    First off, I manage everything myself, own servers, etc.

    Short setup overview.
    I use Cloudflare as DNS and Proxy. Full Strict mode, with “Authenticated Origin Pulls” on. +
    Always Use HTTPS = ON
    Automatic HTTPS Rewrites = ON.
    Everything else is pretty stock in cloudflare.

    Then I have my own local Nginx proxy. Which has the certicates to handle encryption with cloudflare.
    And seperate Centos7/Apache servers for:
    Example.com
    wordpress.example.com
    simple.example.com

    Problem
    My two wordpress installs on example.com and wordpress.example.com are entirely fresh and actually DO WORK, https and all …. BUT… As soon as I publish any changes to either, its when I get “ERR_TOO_MANY_REDIRECTS”. Funny thing is.. thats what I used to fight on Wp-admin page to begin with, now Wp-admin works, but sites get broken.
    Sometimes when visiting main example.com it leads me to wordpress.example!. Or even oppesite I think I experienced.

    At no point does anything happen to simple.example.com which is just simple apache install with sample page.

    A selection of things attempted.
    Changing Themes..
    saving settings page(if updating any broken)
    Saving permalinks page(if updating any broken)…
    WP-CLI Search-replace (To try and find faulty urls in database)
    Defining home and site url in wp-config.
    Clearing my cookies.

    This code in wp-config.php which otherwise did fix my redirection problem on Wp-admin page.

    define('FORCE_SSL_ADMIN', true);
    // in some setups HTTP_X_FORWARDED_PROTO might contain
    // a comma-separated list e.g. http,https
    // so check for https existence
    if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
    $_SERVER['HTTPS']='on';

    Local Nginx proxy sample. (This is the exact same for subdomain, ofc with other servername, IP, and cert)

    server {
      server_name example.com;
    
    location / {
        proxy_pass https://10.10.10.10;
        proxy_set_header X-Forwarded-Proto https;
    }
        listen 443 ssl;
        ssl_certificate /etc/nginx/conf.d/certs/example.com.pem;
        ssl_certificate_key /etc/nginx/conf.d/certs/example.com.key;
        
        ssl_client_certificate /etc/nginx/conf.d/certs/origin-pull-ca.pem;
        ssl_verify_client on;
    }

    UPDATE:
    I hoped to say my 3rd seperate install without subdomain to it had no problems.
    But it’s the same.
    Everything works, until I make a change and try to publish it.
    Admin area will continue to work, but site broken when it worked before.

    • This topic was modified 4 years, 8 months ago by mirky007.
    • This topic was modified 4 years, 8 months ago by mirky007.
    • This topic was modified 4 years, 8 months ago by mirky007.
Viewing 1 replies (of 1 total)
  • Thread Starter mirky007

    (@mirky007)

    FIXED.

    Adding
    proxy_set_header Host $host;
    in my nginx proxy configs did the trick.

    So this can be marked as solved, if i cannot find a button for it myself.

    • This reply was modified 4 years, 8 months ago by mirky007.
Viewing 1 replies (of 1 total)
  • The topic ‘Redirection error after publish – admin page works.’ is closed to new replies.