2

I have multiple nginx sites running on a Digital Ocean droplet. I've installed postfix as a relay to G Suite Gmail.

I only access my email through Gmail itself. So I don't need webmail. Nor have I tried to set one up. And yet my sites all have a subdomain webmail.site.com. Also, all the site's webmail subdomain point to the first site I had setup in nginx. The content of the webmail subdomain is the home page of my first site.

Google has indexed the webmail subdomain and this is the only reason why I know it exists.

I've tried to setup a redirect in nginx but it only works for http://webmail.example.com and not https://webmail.example.com

The former redirects to https://www.example.com but the latter keeps pointing to https://webmail.example.com.

Also, I'm using Let's Encrypt which doesn't provide a certificate for subdomains so it's being marked unsafe by browsers.

How do I disable the webmail subdomain all together or redirect all requests to https://www.example.com?

Here's my nginx config:

server {
    listen 80;
    listen [::]:80;
    server_name  example.com www.example.com;
    return 301 https://www.$server_name$request_uri;
    return 404; # managed by Certbot
}
server {
    server_name *.example.com;
    return 301 https://www.example.com$request_uri;
}
Neuro
  • 21
  • 2
  • 1
    If you don't want the webmail subdomain, why don't you just delete it? Of course, let's encrypt will happily add that name to your cert, but only if you ask it to. – Michael Hampton Aug 08 '18 at 19:15
  • Yeah, I want to delete it. But I don't know how. I don't even know how Google found it. – Neuro Aug 08 '18 at 19:20
  • 1
    Just go into your DNS records and get rid of it. – Michael Hampton Aug 08 '18 at 19:28
  • There's no record that points to webmail. Which record are you talking about? The only MX records I have are that of Google's G Suite. – Neuro Aug 08 '18 at 19:46
  • You have a CNAME webmail that resolves to your naked domain name. – Michael Hampton Aug 08 '18 at 19:47
  • Great, thanks. That seemed to have solved it. The CNAME was a wildcard though. So is CNAME not needed if the domain has no subdomains? Also, why would the webmail subdomain point to another domain? – Neuro Aug 08 '18 at 19:53
  • Side note: If you remove the `*.example.com`, make sure you have a `www.example.com` defined, as `example.com` doesn't cover that. – ceejayoz Aug 08 '18 at 21:55
  • Do you mean www.example.com as a CNAME or A record? – Neuro Aug 08 '18 at 22:25
  • @Neuro Doesn't really matter, either will generally work. You just don't want *no* `www.example.com` record, or half your visitors will risk getting lost. – ceejayoz Aug 12 '18 at 12:09

0 Answers0