简体   繁体   English

如果使用HTTPS,如何获取客户端的IP地址?

[英]How can I get the client's IP address if I am using HTTPS?

If I am using HTTP I can get the normal IP address but if I am using HTTPS it returns the proxy server's IP address. 如果使用HTTP,则可以获取常规IP地址,但是如果使用HTTPS,它将返回代理服务器的IP地址。 How can I get the IP address of the client and not the proxy server? 如何获取客户端而不是代理服务器的IP地址?

A proxy will generally add a X-Forwarded-For header see here which will contain the IP address of the real client. 代理通常会添加一个X-Forwarded-For标头, 请参见此处 ,其中包含真实客户端的IP地址。

Note there's no difference between HTTP and HTTPS in terms of the IP addresses you can see on a request, they will both give you the IP address of the User-Agent that originated the request. 请注意,HTTP和HTTPS在请求中可以看到的IP地址之间没有区别,它们都将为您提供发起请求的User-Agent的IP地址。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM