views:

36

answers:

2

Hello, To keep things simple, please allow the "assumption" that some code requires the use of a full URL, even though the domain is on the same server, i.e. a simple file path cannot be used.

TCP/IP?? Question: If a form action target = "http://this-full-URL.com/postdata" (for example) and that URL is also on the same server, then which happens first?

A) Data is sent "out onto the web", and then returns to the same server, or

B) Before sending any (possibly sensitive) data, the server (Linux, Apache, PHP), first "discovers" the target address is local, so (clearly) no data is sent over the net? Thank you.

+1  A: 

The network software will resolve the hostname to you machine, then the local TCP stack will route the request locally. Traffic won't ever leave the machine, it'll all be in memory on the server.

Will Hartung
Only if the client HTTP agent is executing on the same machine as the server.
Franci Penov
That's what he says in his question. "...even though the domain is on the same server...".
Will Hartung
+4  A: 

The correct answer is always A. :-)

It just happens that the case where the browser and the server are running on the same machine, "the web" will be short-circuited by the local TCP/IP stack. However, Apache and PHP are not involved in that decision; it's pure functionality of the OS networking stack.

However, if your server is behind a NAT gateway or firewall and the DNS name is resolving to the NAT gateway/firewall, the request will be routed to the NAT gateway/firewall and back to your machine. Thus, in order for the routing to stay on the same machine, the DNS name of the host of the target URL has to resolve to the actual IP address of the server machine, not be tunneled to it.

Franci Penov