X-forwarded-for (XFF) is an HTTP request header field that is used to identify the most original IP address of a client that is connected to a Web server through an HTTP proxy or load balancing method. The developer of the Squid cache proxy Server first introduced this HTTP header field and was formally presented by the IETF in the Forwarded-for HTTP header field normalization draft.
The general format of this HTTP header is as follows:
X-Forwarded-For: client1, proxy1, proxy2
Where the value is separated from multiple IP addresses by a comma + space, the leftmost (CLIENT1) is the IP address of the most original client, and the proxy server adds the requested source IP address to the right when each request is successfully received. In the above example, this request successfully passed through three proxy servers: Proxy1, Proxy2 and Proxy3.
Python:
Def setheader (): RANDOMIP = str (random.randint (0, 255) + '. ' + str (random.randint (0, 255)) + '. ' + str ( Random.ra Ndint (0, 255)) + '. ' + str (random.randint (0, 255)) headers = { ' user-agent ': Random.choice (UAS), " Accept-language ":" zh-cn,zh;q=0.8,en;q=0.6 ", ' x-forwarded-for ': Randomip, } return headers
"X-forwarded-for" Web modification guest IP