I’m running an ubuntu jaunty server with 2 network interfaces configured: one public IP, one private. When I request the server IP I get the public IP. If I’ve got multiple interfaces is there a best practice for assuring I’m getting the public one (which is what I want)?
<?php
echo " <table>";
echo "<tr><td>" .$_SERVER['SERVER_ADDR'] ."</td><td>SERVER_ADDR</td></tr>";
echo "<tr><td>" .$_SERVER['SERVER_NAME'] ."</td><td>SERVER_NAME</td></tr>";
echo " </table>";
?>
My impression is that you’ll get the address of wherever the traffic is coming in from, so if you want to always act with regard to the public interface regardless of where your request came from, you’ll have to disregard
$_SERVER['SERVER_ADDR']and determine the IP you want to deal with in code (hardcoding it, analyzing the interface table and looking for something that isn’t on a private network, what-have-you).