0

I have a PHP website on CENTOS which needs to get the contents of its own homepage in order to cache it. To do this I need to use the full URL of it's own domain name that resolves to itself.

I tried doing a Curl -I website.com but the connection comes back as "Connection Refused". It works on any external domain but itself.

I believe there must be a firewall rule that's causing it to block connections from itself but there are none set, and I even tried disabling the firewall completely. There is already a loopback adapter from ifconfig.

user2924019
  • 99
  • 1
  • 12

3 Answers3

2

I managed to solve the problem by using nano to edit the /etc/hosts file and add the domain name of the website to the servers external IP

user2924019
  • 99
  • 1
  • 12
1

Maybe your DNS is messed, you need to check what IP resolves to your domain.

try running dig yourdomain.com A on the machine your are testing. If the response doesn't include your IP address, then maybe the problem is in your DNS.

MarkOne
  • 61
  • 1
  • 2
  • It returned the 127.0.0.1 IP address which I thought was correct. I had to make entries for it to point to the external IP address which worked. I'm not sure why the first option didn't work. – user2924019 Feb 13 '17 at 09:29
1

If your site really listens on 80/tcp port and there is no iptables-related problems, you can try localhost, like this curl -I -H "Host: website.com" localhost. Also, it is possible that your site listens only on https-port (443/tcp), so it can respond to curl -I https://website.com

GreyWolf
  • 76
  • 3