I know that to you it's probably very obvious that it's "not working anymore" but for anybody trying to help you we need to understand what this means precisely. For example - is there an error displayed if you try to visit the test.domain.com website with a web browser (what is the error?), is there anything interesting in the error logs for that site ?
@tialaramex thank you! You are totally right!
When I open Chrome it output HTTPS in red overlined and outputs the following:
Your connection is not private
Attackers might be trying to steal your information from test.domain.com (for example, passwords, messages, or credit cards). NET::ERR_CERT_COMMON_NAME_INVALID
OK. This error says that test.domain.com is presenting a certificate for some other name. Given the other information it seems likely it’s presenting the new certificate, which is for domain.com and www.domain.com but of course not for test.domain.com
Chances are this is a mistake in your nginx configuration, either the new snippet is mistakenly included instead of the old one for the test.domain.com site, or the site configuration overall is wrong and only serving the www.domain.com site not the test.domain.com site to all visitors.
You might be able to get more detailed help by posting all the nginx configuration for people to examine, either here or on other relevant forums since Let’s Encrypt isn’t key to the problem. But I suggest first trying to diagnose it yourself, especially re-reading the configuration slowly to make sure it doesn’t have any obvious goofs in it.
Thank you so much for the help. So, I cleared my browser cache and now the message is a little bit more precise..
Your connection is not private
Attackers might be trying to steal your information from test.domain.com (for example, passwords, messages, or credit cards). NET::ERR_CERT_COMMON_NAME_INVALID
This server could not prove that it is test.domain.com; its security certificate is from domain.com. This may be caused by a misconfiguration or an attacker intercepting your connection.
Proceed to test.domain.com (unsafe)
And sometimes, it says:
test.domain.com normally uses encryption to protect your information. When Google Chrome tried to connect to test.domain.com this time, the website sent back unusual and incorrect credentials. This may happen when an attacker is trying to pretend to be test.domain.com, or a Wi-Fi sign-in screen has interrupted the connection. Your information is still secure because Google Chrome stopped the connection before any data was exchanged.
You cannot visit test.domain.com right now **because the website uses HSTS**. Network errors and attacks are usually temporary, so this page will probably work later.
It means test.domain.com is now trying to use the certificate of domain.com.
It is weird because at the begining test.domain.com was working perfectly with it's generated certificate. Then I generated the domain.com + www.domain.com certificate and update NGINX conf. It stopped working at this time.
So as you suggested, it is a NGINX conf issue.
Let me share my conf.
5 minutes after posting all the details I found the issue…
If you notice, for sites-available/ => test.domain.com
The second server block (for SSL) misses a server_name directive.
So I added that directive test.domain.com and now it works (like a charm).
I would be very happy if someone can give me some light on what happened so I understand.
You had the same problem as this thread. When a request comes in for a name that doesn't match any server_name directives a block is chosen by default. At first this would have been test.domain.com as it was the only one with SSL enabled, then when domain.com was created it became the default.