Obtain the real IP address of a user in the multi-level proxy (Squid) Environment
Source: Internet
Author: User
Obtain the real IP address of a user in the multi-level proxy (Squid) Environment-Linux Enterprise Application-Linux server application information. The following is a detailed description. Problem:
In a simple statement, X-Forwarded-For: which IP address should be used when multiple IP addresses exist?
(This article does not discuss how to obtain the real IP address of a user using apache. If you need it, see:
Original IP log module-mod_extract_forwarded of apache2 in squid reverse acceleration/Proxy acceleration Mode
Http://windtear.net/archives/2004/12/09/000440.html
Original IP log module-mod_extract_forwarded of apache in squid reverse acceleration Mode
Http://windtear.net/archives/2004/10/31/000293.html
)
Answer:
Take the first non-unknown valid IP string in X-Forwarded-
Discussion:
Squid. conf default
Forwarded_for on
If forwarded_for is set to off
X-Forwarded-For: unknown
If unknown exists, just remove it.
Example:
X-Forwarded-For: 192.168.1.11, 192.168.1.12, 192.168.1.13, 192.168.1.10
Your real IP address is 192.168.1.11.
Simulation:
# Telnet 192.168.1.10 80
Trying 192.168.1.10...
Connected to windteartest (192.168.1.10 ).
Escape character is '^]'.
GET, HTTP, 1.1
HOST: test.com
X-Forwarded-For: 192.168.1.11, 192.168.1.12, 192.168.1.13
Server cache. log can be seen: (the environment settings are omitted here, and an endless loop is intentionally set for ease of viewing)
19:36:21 | WARNING: Forwarding loop detected:
Client: 192.168.1.10 http_port: 192.168.1.10: 80
GET http://test.com/https/1.0
Host: test.com
By: 1.1 squid10.test.com: 80 (squid/2.5.STABLE13)
X-Forwarded-For: 192.168.1.11, 192.168.1.12, 192.168.1.13, 192.168.1.10
Cache-Control: max-age = 600
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service