I am facing a bit of an issue when setting up WordPress with Nginx as reverse proxy to Apache backend.
All the pages are loading, but i get an error when i try to login to wp-admin dashboard.
The error is Sorry, you are not allowed to access this page.
I have checked my file permissions, database prefix,.htaccess and even usermeta admin privileges in the db, all seem to be perfect.
The site was working perfectly fine before i setup nginx reverse proxy.
Here is my apache2 config:
<VirtualHost *:8081>
DocumentRoot "/mnt/NAS/wp_data/wordpress/"
ServerName my_site_url
ServerAlias www.my_site_url
<Directory "/mnt/NAS/wp_data/wordpress/">
Options MultiViews FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Here is my apache ports.conf:
#Listen 80
Listen 8081
Here is my nginx config:
server {
listen 80;
listen [::]:80;
server_name my_site_url;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name www.my_site_url my_site_url;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:8081;
}
ssl_certificate /var/www/mycert/certificate.pem;
ssl_certificate_key /var/www/mycert/private.key;
}
Last but not least my wp-config.php is as default and i haven't added anything else apart from
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) {
if ( 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
$_SERVER['HTTPS'] = 'on';
}
}
if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_REAL_IP'];
}