I am trying to test a subdomain hosted in a hosting service while simultaneously running the same subdomain in an in-house server,
by adding an entry to the hosts file.
The idea is to make my test client (a windows 10 desktop) think that the subdomain being tested resolves to the IP address I added in the hosts file,
not the global IP address that the authoritative DNS returns.
Is it possible?
Background:
There are several subdomains, say, www1-test-com, www2-test-com, www3-test-com, etc,
each with their own websites, running from an in-house server. The DNS server is also in-house.
I am planning to operate one of these subdomain's website (say, www1-test-com) from a hosting server in the near future.
The hosting service allows multiple domains, and our own ssl certificate.
So I added the subdomain (www1-test-com) to the admin console of the hosting service,
and uploaded the ssl that is currently being used in the in-house server. (All the subdomains use the same ssl certificate.)
The date that I want to "move" the www1-test-com from in-house to the rental server is a little ahead,
so I want to see if the www1-test-com website hosted at the rental server works properly, before that move.
So, as mentioned earlier, I added a line in hosts file:
nnn.nnn.nnn.nnn www-test1-com
The nnn is global, fixed IP address of the www1-test-com website hosted at the rental server.
The content in the hosting site's www-test1-com's doc root folder (/www) is just an index.html file that outputs "hello world".
No .htaccess, or redirection script.
Now, when I access the https://www-test1-com from my browser, I get
//--------------------------------------
www1-test-com redirected you too many times.
Try clearing your cookies.
ERR_TOO_MANY_REDIRECTS
//--------------------------------------
I cleaned cookies, deleted browser history, restarted the desktop. Nothing helps.
The hosting service's HelpDesk told me their server hasn't received the request, the problem is in my side.
The in-house www1-test-com's server log (/var/log/httpd/access_log) does not show any access.
I also tried wget in cygwin terminal:
$ wget https://www1-test-com
--2022-03-21 21:17:59-- https://www1-test-com/
Resolving www1-test-com (www1-test-com)... nnn.nnn.nnn.nnn
Connecting to www1-test-com (www1-test-com)|nnn.nnn.nnn.nnn|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www1-test-com/ [following]
--2022-03-21 21:17:59-- https://www1-test-com/
Reusing existing connection to www1-test-com:443.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://www1-test-com/ [following]
(repeat)
and finally, 20 redirections exceeded.
Chrome's Developer's Tool (network tab) shows 19 lines of 301, a failed, a few 200 and 19 lines of 302 and it seems to repeat.
I would appreciate any hints.
Thank you.