How to redirect www to non-www using meteorup (mup) tool?

I have been trying to figure out how to redirect www to a non-www site. I am using meteorup (mup) for the deployment. However, I couldn’t see any configuration to do that in mup documentation.

My requirement is if someone enters https://www.xyz.com should be redirected to https://xyz.com

Note: I have also checked those old questions related to this topic and they are really helpful anymore.

Please input your views on this. Thank you.

I’ve done the following:

  1. Add a DNS CNAME record pointing www to yourdomain.com
  2. In your mup.js config, add the following in the proxy section
proxy: {
    domains: 'yourdomain.com, www.yourdomain.com',
    ...
    nginxServerConfig: './nginx.conf',
  },
  1. Add a nginx.conf file next to your mup config, with the following:
if ($host != "yourdomain.com") {
  return 301 $scheme://yourdomain.com$request_uri;
}
  1. make sure you run: mup proxy setup
4 Likes

Hi @kimar ,

Thanks for sharing the answer. This resolved my issue. Thank you again.