• Resolved canoreom

    (@canoreom)


    I tried to install latest version of wordpress as of 03. 04. 2023. on Ubuntu 22.04.

    I put another nginx module in front for reverse proxy as there’s multiple devices that need port 80 and 443 incoming connection.

    I successfully accessed installation page but then logging into admin page shows ‘Sorry you are not allowed to access this page’ error.

    php wp-cli user list shows my email as administrator.

    I’m pretty sure it’s not a plugin issue as I didn’t have chance to install any and it’s less likely nginx issue since I can access first default post without problem.

    I tried again after drop database wordpress; from mysql but still the same.

    I tried everything I could come up and everything I could find on the internet but still of no use. Any advice will be appreciated. below is my github gist of my setup

    https://gist.github.com/Canorus/6f67f326100de6afb4e071c232af3941

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter canoreom

    (@canoreom)

    adding below code to wp-admin.conf solved my issue.

    define('.COOKIE_DOMAIN.', 'www.mydomain.com');
    define('.SITECOOKIEPATH.', '.');
    
    if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $list = explode(',',$_SERVER['HTTP_X_FORWARDED_FOR']);
            $_SERVER['REMOTE_ADDR'] = $list[0];
      }
    define( 'WP_HOME', 'https://www.mydomain.com' );
    define( 'WP_SITEURL', 'https://www.mydomain.com' );
    $_SERVER['HTTP_HOST'] = 'www.mydomain.com';
    $_SERVER['REMOTE_ADDR'] = 'https://www.mydomain.com';
    $_SERVER[ 'SERVER_ADDR' ] = 'www.mydomain.com';
    
    if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
           $_SERVER['HTTPS']='on';

    I can confirm that this snippet of code worked for me. ??

    I’d like to clarify that I added it to wp-config.php, and that I had to add it to the beginning of the file, after <?php and introductory comments. Placing this code at the bottom of the file did not work for me.

    Many thanks!

    • This reply was modified 1 year, 8 months ago by autofyrsto.
    • This reply was modified 1 year, 8 months ago by autofyrsto.
    • This reply was modified 1 year, 8 months ago by autofyrsto. Reason: Trying to get the file name to stand out!
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘WP behind nginx reverse proxy’ is closed to new replies.