Please be aware that a 301 is intended to be a permanent and should be cached by your browser. When testing a change in your configuration: after reloading the nginx configuration test from a new private/incognito browser window.
I am wanting all https://www.my-clients-domain.com
to rewrite to https://my-clients-domain.com
Then I would for starters ensure that when you redirect from plain HTTP to HTTPS, that your visitors immediately get redirected to https://my-clients-domain.com
and don't get redirected first from http://www.my-clients-domain.com
to https://www.my-clients-domain.com
where the immediately get a second redirect to https://my-clients-domain.com
Rather than a redirect with a $host
parameter use the desired domain and have a concise:
server {
listen 80;
server_name my-clients-domain.com www.my-clients-domain.com;
return 301 https://my-clients-domain.com$request_uri;
}
Your SSL server block looks OK already.
I would expect a second block for the bare domain, that holds your web content: (Assuming that the certificate /etc/letsencrypt/live/my-clients-domain.com/
is also valid for www.my-clients-domain.com
)
server {
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
server_name www.my-clients-domain.com;
return 301 https://my-clients-domain.com$request_uri;
ssl_certificate /etc/letsencrypt/live/my-clients-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my-clients-domain.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
server_name my-clients-domain.com;
root /var/www/default/htdocs;
ssl_certificate /etc/letsencrypt/live/my-clients-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my-clients-domain.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
Or slightly more concise:
server {
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
server_name my-clients-domain.com www.my-clients-domain.com;
root /var/www/default/htdocs;
if ($host = www.my-clients-domain.com) {
return 301 https://my-clients-domain.com$request_uri;
}
ssl_certificate /etc/letsencrypt/live/my-clients-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/my-clients-domain.com/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}