tags:

views:

43

answers:

3

I'm doing a PHP cURL post, using a complete URL (http://www.mysite.com), from one page to another on the same site. (I know this isn't the best way to do it; but for my purpose this is what I need)

My question is:

Will the cURL post still go out across the internet, do a name lookup and travel a route as though it were a post coming from a different site. Or will the post stay on the servers local network?

A: 

No. The post itself (unless you have multiple interfaces and your routing is totally screwed up) will not traverse the internet. Your local host ought to be able to resolve its own name as well, but there is a possibility that a DNS request will be made to determine the IP address corresponding to the name. I would hope that the network stack implementation on your system would prevent the post's packets from even hitting the wire (similar to localhost), but I wouldn't count on it.

tvanfosson
that is only true if the server has a public ip and is not in a NAT'd DMZ
Tim Hoolihan
I would expect that if the system is behind a firewall/load-balancer that you'd use the name/ip address corresponding to the actual (non-proxied) name/address.
tvanfosson
+2  A: 

There are multiple parts to the request, the dns lookup and the get or post to the site.

DNS Records are usually cached on most OSes, so it's rather unlikely that the server would have to do a dns lookup for it's own external ip, but it's possible.

As for the post, let's assume a basic layout:

Firewall         =>   DMZ Apache PHP Server (www.mysite.com)
222.xxx.xxx.123  =>   192.168.0.2

And mysite.com resolves to 222.xxx.xxx.123, then your request will go to your firewall's external interface and bounce back in. That's not terribly public traffic, but it goes out none-the less.

However, if you wanted to bypass that, you could put an entry in the host file of the server to say

127.0.0.1 mysite.com

(assuming you control the server, ie not shared hosting)

Tim Hoolihan
A: 

It depends on your network setup. Many sites have a domain name pointing to the IP address of a front facing router or load balancer which forward the request to the web server.

If that's the case a request to your own site can make a round-trip to the router. Though it's unlikely that the request will go through the internet unless you have a very unusual setup (such as round robin DNS with multiple datacenters).

You can avoid the round-trip by associating the site FQDN to the loopback interface in your webserver /etc/hosts which will also save you a DNS request.

Alexandre Jasmin