There is no http_x_forwarded_for variable in request. servervariables. Only the remote_addr variable can be used, but both variables can obtain the Client IP address. So what is the difference between them?
Use request. servervariables ("remote_addr") to obtain the IP address of the client. However, if the client is accessed by a proxy server, the IP address of the proxy server is obtained instead of the real IP address of the client. To obtain the real IP address of the client through the proxy server, use request. servervariables ("http_x_forwarded_for") to read.
However, not every proxy server can use request. servervariables ("http_x_forwarded_for") to read the real IP address of the client, some of which are still the IP address of the proxy server.
Note that if the client is not accessed through the proxy server, the value obtained using request. servervariables ("http_x_forwarded_for") will be null. Therefore, if you want ProgramYou can use this method as follows:
......
Userip = request. servervariables ("http_x_forwarded_for ")
If userip = "" Then userip = request. servervariables ("remote_addr ")
......
That is, if the client uses the proxy server, the value of http_x_forwarded_for is obtained. If the client does not pass the proxy server, the value of remote_addr is obtained.
Of course, the above practice is not omnipotent, as mentioned in the third paragraph, have you considered that if the user is using Level 2 proxy, Level 3 proxy, and Level 4 proxy ........