Nginx www to non www redirect - jigneshpshah/greycube_helpmanual GitHub Wiki
put this as the first server block in nginx.conf file
/home/frappe/frappe-bench/config
================================================
server
{
listen 80;
if ( $host ~ ^www\.(?<domain>.+)$ ) {
return 301 $scheme://$domain$request_uri;
}
====================================================
For this to work in safari .
- create a wildcard SSL
sudo service nginx stop
cd /opt
./certbot-auto certonly --manual --preferred-challenges=dns --agree-tos -d *.domain.com
OR
./certbot-auto certonly --manual --preferred-challenges=dns --agree-tos -d domain.com -d www.domain.com -d sub.domain.com
add the given value of _acme-challenge.domain.com to dns panel Text : _acme-challenge Value : from previous command
you can check from your local whether it is added or not
dig -t TXT _acme-challenge.domain.com
sudo service nginx restart
put this as the first server block in nginx.conf file
/home/frappe/frappe-bench/config
================================================
server {
listen 80;
server_name www.domain.com;
return 301 https://domain.com;
}
================================