I'm not sure if this is an issue with changing the domain name on a WordPress site, or an issue with configuring SSL certs between Nginx and Cloudflare. I suspect it's a bit of both.
I've setup two 2 different WordPress sites, one with Digital Ocean, the other with Scaleway, both using the respective pre-built WordPress Ubuntu images.
With Digital Ocean, Apache comes preconfigured, and with Scaleway they have Nginx.
When I pointed my domain to the Apache-based host, everything 'just worked', including HTTPS.
When I pointed my domain to the Nginx-based host, all my asset files fail because the requests go out via HTTP, so I get back "Referrer Policy: no-referrer-when-downgrade". This seems to be that PHP doesn't detect HTTPS.
Do I need additional setup steps for Nginx to work with Cloudflare? Why does Cloudflare SSL work with Apache without any extra steps?
Here is my current vhost config for nginx. It has some minor updates from the original default state.
server {
listen 80 default_server;
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
client_max_body_size 200M;
root /var/www;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# proxy_set_header X-Forwarded-Proto $scheme;
}
location ~* \.(eot|otf|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
# add_header Referrer-Policy origin always;
# proxy_set_header X-Forwarded-Proto $scheme;
}
}
[UPDATE]
Adding this PHP code to my project provided a partial fix. At least, with this added, the site and all the assets load.
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS'] = 'on';
However, I can't login with my WP user. I always get this message:
You do not have sufficient permissions to access this admin page.
Reason: The current user doesn't have the "read" capability that is required to access the "Dashboard" menu item.
UPDATE:
After deleting all files in the plugins directory, the message became this:
Sorry, you are not allowed to access this page.
Also went thru the process of download the WP database and rewriting every occurrence of the domain name with the new domain name, but after importing the data, I still can't login.