In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to get client-side IP in server-side applications. Many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
If there is a request header for x-forwarded-for, take the first IP, otherwise take the remoteAddr to establish a connection to the socket.
X-forwarded-for has basically become a standard HTTP header based on proxy. The format is as follows. You can see that the first IP represents its real IP. Please refer to MDN X-Forwarded-For [1].
X-Forwarded-For: 203.0.113.195, 70.41.3.18, 150.172.238.178
X-Forwarded-For:,
Here is how koa gets the IP
Get ips () {
Const proxy = this.app.proxy
Const val = this.get (this.app.proxyIpHeader)
Let ips = proxy & & val
? Val.split (/\ sstories,\ slots /)
: []
If (this.app.maxIpsCount > 0) {
Ips = ips.slice (- this.app.maxIpsCount)
}
Return ips
}
Get ip () {
If (! this [IP]) {
This [IP] = this.ips [0] | | this.socket.remoteAddress | |''
}
Return this [IP]
}
After reading the above, do you have any further understanding of how to obtain client-side IP in server-side applications? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.