I'm using CloudFlare for DNS and Digital Ocean for servers.
Let's call my website "example.com". It has been working fine.
I've now created a second server, which has a different IP. I want a new subdomain "staging.example.com" to point to this second IP.
In CloudFlare, I tried to create a second "A" record. Here is the export of my settings (partially redacted and also changed to use an example domain name):
;; A Records
example.com. 1 IN A 192.■■■.135.106
staging.example.com. 1 IN A 157.■■■.174.87
Browsing to example.com still works.
However, browsing to staging.example.com results in "Error 522 Connection timed out".
What am I doing wrong? How can I have a subdomain point to a different IP than its parent domain?
P.S. I thought maybe my Nginx config was the problem, but I now doubt that it's the problem because I was able to temporarily change it to say example2.com instead of staging.example.com and then temporarily change the CloudFlare DNS of this other domain that I own (example2.com), and it loaded fine.
P.P.S. Now for debugging purposes my Nginx config says:
server_name staging.example.com example2.com;
And I’ve left the subdomain “A” record in CloudFlare DNS as “DNS only” (gray cloud).
Then in my CloudFlare DNS for example2.com (a different domain that I own), I temporarily pointed it to 157.■■■.174.87.
And browsing to staging.example.com results in “This site can’t be reached staging.example.com took too long to respond. ERR_CONNECTION_TIMED_OUT” .
But browsing to example2.com works.
This leads me to believe that the Nginx config is fine. Right? So what is wrong?