1
votes

I'm currently trying to migration my multisite wordpress installation from ionos to aws.
On ionos, I have a single ubuntu server with plesk, nginx, apache, php 7.2.28, letsencrypt and mariadb.
On AWS, I have an ELB (doing the ssl termination), an amazon linux 2 (based on centos) instance with apache / php 7.2.34 / wordpress and another instance for mariadb.
I took a DB dump from production and restored it (untouched) on this new environment (same domain as production, accessed locally by modifying the /etc/hosts file).
I copied our wordpress codebase from production, modified the apache config file to fit the new folder structure and modified wp-config to reach the new DB instance and to stop forcing the ssl redirection.
The landing page works, I can access the website and the public pages, but when I try to login, it says permission denied ("Sorry, you are not allowed to access this page.").
It seems like the authentication works because I can see the admin-bar on top of the homepage. When I try to access a page inside the wp-admin, I get the aforementionned error.
While debugging the code, I found out that the global $current_user has an ID of 0 when accessed from the function user_can_access_admin_page.

Here are the debugging details with the attempt to access the https://mydomain.tld/wp-admin/widgets.php page:

What's weird is that it works on production and I can't understand what's different between these two environments. Like I said, DB is exactly the same, codebase is the same, the only change I made is adding the following code at the bottom of wp-config to deal with ssl termination properly

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

phpinfo() shows that both servers have the same libraries installed.
I thought that the issue could be due to a different key/salt in wp-config than the one used to store the encrypted passwords, but they are the same as the one on production.
I've read the the global $current_user can be 0 if the init hook is not finished, but I doubt this is the case:

  • it works on production
  • this is part of the wordpress standard codebase

I've checked the permission for my user in the DB: it is a superadmin, has the level 10 with manage-network capabilities (and like I said, it's the same DB as prod, where it works fine)

I checked the file/folder permissions and they seem fine.

1
If $current_user is 0, and permission is denied, it seems likely that you're not logged in. It could be a cache problem that causes the admin bar to show. - Matts
I can login properly (and logout as well). When I debug on the landing page, I can see that $current_user is populated correctly with the data of my user. - Nicolas RTT
Hi @NicolasRTT It's an weird bug and very hard to provide solution without debugging on the installation. I'm willing to assist you to debug the issue. Please DM me via skype live:rsm0128 - Intelligent Web Solutions
For your information, WordPress uses cookie to authenticate. So please check the URL first for the admin page. Double confirm http|https and domain name first. - Intelligent Web Solutions
It sounds like your MS is folder, not domain, right? Are you trying to log into the "root site" or a sub-site, and regardless, can you get into any? Otherwise, I'd start looking at plugins next, especially any MU ones. Use the CLI to start deactivating them and see if anything changes. - Chris Haas

1 Answers

1
votes

WordPress uses cookie to authenticate. So please check the URL first for the admin page. And then double confirm http|https and domain name first.