Lets Encrypt SSL & redirect for http to http and www to non www https - jigneshpshah/greycube_helpmanual GitHub Wiki
https://wwww.domain.com to https://domain.com
To install Lets Encrypt SSL and also redirectNote : replace domain.com with the actual domain
[1] Check at https://www.sslshopper.com/ssl-checker.html#hostname=https://www.domain.com It used to give error in last point i.e. 'Name Mismatch Error' It means we have no certificate for WWW
[2]
sudo service nginx stop
cd /opt
sudo ./certbot-auto certonly --manual --preferred-challenges=dns --agree-tos -d domain.com -d www.domain.com
It would give 2 challenges
Get both values and pass it to DNS panel and wait before hitting 2nd enter
Please deploy a DNS TXT record under the name
_acme-challenge.domain.com with the following value:
Aa_4eGEbdFVEar6ABCFST7oy7C-H2t97APV45oTo
Press Enter to Continue
Please deploy a DNS TXT record under the name
_acme-challenge.www.domain.com with the following value:
rNmIw235bA7MnE45z6h32yXGu9foqduJEbrBPmdROKIj
[3] In DNS panel add acme withOUT the domain name i.e
TXT | Value |
---|---|
_acme-challenge | Aa_4eGEbdFVEar6ABCFST7oy7C-H2t97APV45oTo |
_acme-challenge.www | rNmIw235bA7MnE45z6h32yXGu9foqduJEbrBPmdROKIj |
[4]sudo service nginx reload
[5] Check on https://www.sslshopper.com/ssl-checker.html name mismatch error is gone
[6] Do following steps in cd bench/config nano ngix.conf to redirect
https://www.domain.com --> https://domain.com
It should have 2 server blocks at the end for redirection
# http to https redirect
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://$host$request_uri;
}
# https://www. to https:// redirect
server {
listen 443;
server_name www.domain.com;
return 301 https://domain.com$request_uri;
}