Note that there are some explanatory texts on larger screens.

plurals
  1. POphp / ajax REMOTE_ADDR set to IP of bogus network adapter
    primarykey
    data
    text
    <p>today I came a across a pretty strange behaviour of an php based application of mine. In a certain part of the system there's an UI making use of AJAX-calls to fill list boxes with content from the backend.</p> <p>Now, the AJAX listener performs a security check on all incoming requests, making sure that only valid client IPs get responses. The valid IP are stored in the backend too.</p> <p>To get the client's IP I used plain old</p> <pre><code>$_SERVER['REMOTE_ADDR'] </code></pre> <p>which works out for most of the clients. Today I ran into an installation where remote_addr contained the IP of an network adapter which was'nt that one which performed the actual communication for my application.</p> <p>Googling around agve me <a href="http://roshanbh.com.np/2007/12/getting-real-ip-address-in-php.html" rel="noreferrer">Roshan's Blog entry on the topuic</a>:</p> <pre><code>function getRealIpAddr() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet { $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))//check ip is pass from prxy { $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } </code></pre> <p>Sadly the problem persists.</p> <p>Did anybody ever stumble into this sort of problem (actually I don't think that I discovered a completly new issue ^^) and has an idea for me how to fix this?</p> <p><strong>EDIT:</strong></p> <p>I'm on </p> <ul> <li>PHP Version 5.2.9-1</li> <li>Apache/2.2.9 (Win32) </li> </ul> <p>The communication is done via a regular LAN card. Now the actuall client has several devices more. VMNet adapters and such.</p> <p>I'm wondering how a client configuration can 'disturb' a web server that much...</p> <p>TIA</p> <p>K </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload