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;
}