http://www.chedong.com/tech/cache.html#compatible
Cache compatibility design for web applications
After the agent, since the intermediate layer is added between the client and the service, the server cannot directly get the client's IP, and the server-side application cannot be returned directly to the client through the address of the forwarding request. However, in the HTTD header information of the forwarding request, it adds http_x_forwarded _ ???? information. To track the original client IP address and the original client address: the following is 2 examples, to illustrate the design principle of cache and compatibility applications:
'ASP application for a name server address needs: Do not reference HTTP_HOST / SERVER_NAME, determine whether there HTTP_X_FORWARDED_SERVER function getHostName () dim hostName as String = "" hostName = Request.ServerVariables ( "HTTP_HOST") if not isDBNull (Request .ServerVariables ( "HTTP_X_FORWARDED_HOST")) then if len (trim (Request.ServerVariables ( "HTTP_X_FORWARDED_HOST")))> 0 then hostName = Request.ServerVariables ( "HTTP_X_FORWARDED_HOST") end if end if return hostNmae end function // need for a Record the PHP application of client IP: Do not reference Remote_addr directly, but use http_x_forwarded_for, function getUserip () {$ user_ip = $ _server ["remote_addr"]; if ($ _server ["http_x_forwarded_for"]) {$ user_ip = $ _Server ["http_x_forwarded_for"];}}
Note: http_x_forwarded_for If you have passed multiple intermediate proxy servers, what can be a comma-divided address, such as: 200.28.7.155, 200.10.25.77 Unknown, 219.101.137.3 Therefore, in many old database designs (such as BBS) often The field used to record the client address is set to 20 bytes. I often see the following error message:
Microsoft Jet Database Engine Error '80040E57'
The field is too small without accepting the number of data to be added. Try to insert or paste less data.
/inc/char.asp, line 236
The reason is that when designing client access addresses, the relevant user IP field size is preferably designed to 50 bytes. Of course, the chances of 3 or more agents are also very small.