Question
Nginx - SSL and Handling www / non.www domains
Hi,
I’m writing to confirm my implementation of SSL and www.mydomain.com
and mydomain.com
(i.e. without www) is correct.
I have certs already purchased from name.com. I’ve got those in place and referenced in the default file in the path /etc/nginx/sites-enabled
and checked against sudo nginx -t
to ensure syntax is ok.
This looks like:
server {
listen 443 ssl;
server_name www.mydomain.com mydomain.com;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_certificate /home/nodeapp/www.mydomain.com.chained.crt;
ssl_certificate_key /home/nodeapp/www.mydomain.com.key;
}
I’ve added by www.mydomain.com and mydomain.com as domains, so dokku domains node app
shows:
mydomain.com
www.mydomain.com
The command dokku certs:info mydomain
shows the certificate details with:
=====> Common Name(s):
=====> www.mydomain.com
=====> www.mydomain.com
=====> mydomain.com
Then in my Cloudflare DNS settings (where i also have redirect from non www to www with https) I have 2 records:
A record -> mydomain.com -> points to my droplet IP
CNAME record -> www -> points to @ - is an alias of mydomain.com
Advice/confirmations would be appreciated.
Many Thanks
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
Also to note - its fully working. I thought it was as the Cloudflare SSL was taking over. However now I’ve disabled it when going to the URL - I get
too many redirects occurred
.And In the
sudo cat /var/log/nginx/error.log
- I get the following: