How does ASP get real IP addresses?

xiaoxiao2021-03-06  55

How does ASP get real IP addresses?

Using Request.SerVariables ("Remote_ADDR") in ASP to get the client's IP address, but if the client is accessible to use the proxy server, the take is the IP address of the proxy server, not the real client IP address. To obtain a real IP address of the client through the proxy server, use the request.servervariables ("http_x_forwarded_for") to read.

However, it is not paying attention to every proxy server to read the client's true IP with Request.ServerVariables ("http_x_forwarded_for"), and some use this method reads the IP of the proxy server.

One thing to note is that if the client does not pass the proxy server to access, the value taken by Request.ServerVariables ("http_x_forwarded_for") will be empty. Therefore, if this method is to be used in the program, it can be processed:

......

Userip = request.serverVariables ("http_x_forwarded_for")

IF userip = "" "" Userip = Request.serverVariables ("remote_addr")

......

That is: If the client passes the proxy server, take the value of http_x_forwarded_for, if not through the proxy server, take the value of Remote_ADDR.

转载请注明原文地址:https://www.9cbs.com/read-116690.html

New Post(0)