Which Happens First? Anyone Know Exactly How The Apache Server Will Handle This Request?
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 r开发者_开发知识库eturns 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.
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.
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.
精彩评论