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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
movefilesAuthor Commented:
Turns out I need to add the internal IP to my /etc/hosts file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
INTRODUCING: WatchGuard's New MFA Solution

WatchGuard is proud to announce the launch of AuthPoint, a powerful, yet simple, Cloud-based MFA service designed to eliminate the vulnerabilities that put your data, systems, and users at risk.

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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.