There are a lot of subdomains hosted on our platform the following way:
server {
listen 443 ssl;
server_name *.company.com;
//...
}
Unfortunately this matches requests with www.something.company.com but the SSL key does not support this and I would like to redirect requests starting with www. to the rest of the request eg: something.company.com.
What is the best way of doing that?
I was trying using the following that did not work:
server_name *.company.com;
if ($host ~* ^www\.(.*\.company\.com)$) {
return 301 $scheme://$1;
}