Finally solved the problem. To force all pages to SSL and non www to www redirect.
I have NOP 4.3 on Ubuntu Linux with nginx server and nothing worked for me except adding two if statements (at the end of the config); One to redirect to SSL and the other to forward non-www to www.
here is my nginx config:
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
# Use only TLS
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
ssl_certificate /etc/ssl/certs/mydomainname_bundle.crt;
ssl_certificate_key /etc/ssl/private/mydomainname.key;
server_name _;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
gzip off;
}
#redirect http to https, if I don't add the if statement here, it goes into an infinite loop with too many redirects
if ($scheme = "http") {
return 301 https://www.mydomainname.com$request_uri;
}
#to redirect non www to www
if ($host = "mydomainname.com") {
return 301 https://www.mydomainname.com$request_uri;
}
}