Www to non-www redirect

WordPress site created with easy engine and lets encrypt on root domain.

So, example.com. Any traffic to www.example.com gets a 503 Bad gateway error.

I have tried to follow all the examples in the forum, but nothing seems to work.

Can you tell me the exact location of files to edit and change that will redirect all traffic from www.example.com to the example.com that was created with ee?

DigitalOcean Ubuntu 16.04.5 host.

You gotta set a www CNAME in your DNS.

that is in the dns settings

I don’t know if anyone has indicated this as a problem on GitHub yet but if you setup a site like example.com the redirect settings for the www subdomain doesn’t get set. The easiest way to do this is to turn on SSL for your domain. It will make a second config file for your nginx proxy called example.com-redirect.conf which will handle the www redirect.

You could attempt to go directly to the docker’s config folder and make your own. Not 100% sure that will work but it is a simple enough fix to turn on SSL and recommended no matter the content of your site.

/var/lib/docker/volumes/global-nginx-proxy_confd/_data

This is some example code from that redirect file.

server {
	listen  80;
	server_name  www.example.com;
	return  301 http://example.com$request_uri;
}

If you aren’t planning to use SSL then use the settings above or just enable SSL and it will create the correct redirect file for you.

Not 100% sure but given how Nginx is configured and how a CNAME works I would guess that wouldn’t help. He is getting the 503 because he already has a CNAME set for www and is getting to the server but when the server sees he is looking for a sub-domain it can’t find it just gives him a 503.

Yeah idk, seems like people are having a lot of problems.

Change the dns settings after login in to hosting. Then go to domain setting, enter into Cname. and change what you want to do.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.