I have this situation that utterly baffles me:
The setup
a newly setup server (centos 7, apache, mysql, nothing fancy) that hosts a simple php app that I need to interact with from my main app on another server. This service is setup to run on service-name.domain.tld while the main app is on domain.tld (just mentioning in case it make any difference).
The problem
For some reason when I try to access the service app from the main server I get an endless loop of 302 redirects.
If I do a curl -D - http://service-name.domain.tld
from the main server I get:
HTTP/1.1 302 Found
Date: Wed, 03 Aug 2016 12:30:26 GMT
Server: Apache
Location: http://service-name.domain.tld
Content-Length: 218
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://email-blasts.upgradesale.co">here</a>.</p>
</body></html>
If I do the same command from my computer, the result is
HTTP/1.1 200 OK
Date: Wed, 03 Aug 2016 12:31:39 GMT
Server: Apache/2.4.6 (CentOS) PHP/5.6.24
X-Powered-By: PHP/5.6.24
Cache-Control: no-cache
Content-Length: 30
Content-Type: text/html; charset=UTF-8
Welcome.
As it should be. Same happens for any request I make (even static files). Also I should specify same situation happens for wget
and get_file_contents
in php
I'm really lost right now, not knowing where to go from here. So any kind of direction is greatly appreciated.
UPDATE #1:
I should mention the 2 servers are not on the same network. The main app is hosted on LiquidWeb and the new server is on Linode.
Also to point the subdomain to the Linode server I created an A record in CPanel's DNS editor.
Running ping from the domain.tld server yields:
64 bytes from li1014-180.members.linode.com (xx.xx.xx.xxx): icmp_seq=1 ttl=64 time=0.022 ms
Same command from my local computer:
64 bytes from (xx.xx.xx.xxx): icmp_seq=0 ttl=52 time=114.982 ms
Following Damiano's instructions running tcpdump I found out that requests from the main server don't reach the new server, instead seems like the main server also responds. The quest continues to figure out why.
Also the main server is running CPanel so that might have something to do with this...
UPDATE 2
While running sudo tcpdump -n -i eth0 icmp
on the service server, if I ping service-name.domain.tld
from my local machine, I can see the traffic coming in and out on the server, but same command run from the main server gives me nothing on the service server (same goes if I filter for http traffic with tcpdump, and making curl requests).
UPDATE 3
I gave up and cloned the Linode, got a new IP and now it works fine... ¯_(ツ)_/¯