cURL or wget calling URL living on same server?

I am trying to execute a URL from my server via cURL or wget - the URL is on a domain served from my local server where I'm trying to execute the cURL/wget command and the domain never seems to resolve. I have no problem running those commands on a site hosted outside of my server (www.cnn.com, for example). I have also tried accessing via IP address to no avail. The only reason we need to use a web address as opposed to having command-line php run the page directly is that there are apache server variables used in the code that won't be defined if run outside of apache.

Does anyone know of a workaround for this?
movefilesAsked:
Who is Participating?
 
movefilesConnect With a Mentor Author Commented:
Turns out I need to add the internal IP to my /etc/hosts file.
0
 
movefilesAuthor Commented:
As a follow up, here is the output received from a wget call
>wget -O - -t 1 https://mysite.com/test.php
Resolving mysite.com... <ip address>
Connecting to mysite.com|<ip address>|:443...

And it stops there.
0
 
allen-davisCommented:
You might want to consider removing the IP/name mapping from the hosts file and having it added to your corporate DNS solution or your provider's DNS server hosting your domain.  If you ever move this site to a new server, you will have to remember to move the host name with it.
0
Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

 
The--CaptainCommented:
allen-davis - why would you add the internal IP to external DNS?  I don't think that's the solution.

This sounds like the ancient NAT problem - The internal machine send packets to the the external IP which represents itself in the DNS, but is actually an IP on an external router/firewall which is forwarded to the internal machine.  The internal machine receives these packets, which have a source address of its internal IP.  It then replies with packets to its own internal IP, from its *internal* IP (or potentially localhost).  The TCP/IP stack on the machine sees these replies, but since they are sourced from the internal IP (or localhost) rather than the external IP (which was where the original packets were sent), it discards them.

Solution for *all* internal hosts (rather than just one machine) is to either use split-DNS on a local DNS server (internal machines receive the internal IP, and external hosts receive the external IP when sending DNS requests), or source NAT all packets to the internal machine as originating from the local firewall/router

Cheers,
-Jon
0
 
allen-davisCommented:
Jon--you're right.  I unfortunately did not read carefully and missed the "INTERNAL" part of the statement.  If it is split horizon DNS, I still believe the hosts file could cause issues long term if the IP could be registered with an internal DNS server but internal IPs should definitely not be added to external DNS servers.

My apologies for any confusion my statement may have caused.
0
 
The--CaptainCommented:
No problem.

I agree with your overall concern about adding specific hostfile entries that should be part of DNS - the author's solution, while temporarily viable, is certainly a kludge.

Cheers,
-Jon
0
All Courses

From novice to tech pro — start learning today.