网站使用了CDN后无法获取到访客真实IP的解决办法
方法技术介绍
现如今,网络建站的门槛越来越低,大多数人都喜欢建立个人网站以及博客类型站点,而个人网站一般我们不会选择高防服务器或高防IP,一般草根站长也承担不起这么高额的服务器费用,所以一般使用普通轻量服务器+大厂高防CDN加速的方式来建站来,这样有助于防御我们的服务器不被受到CC/DDOS攻击,CDN可以隐藏源服务器的IP,同时还能起到加速网站的作用,一举多得。那么问题来了,如果使用了CDN,那么服务器该如何获取真实的用户IP呢?默认获取到的都会是CDN的节点IP,下面简俊飞来给大家介绍非常简单实用的两行代码;即可解决我们自己的网站无法获取用户真实IP的苦恼。
获取用户真实IP的方法
首先找到NGINX的nginx.conf文件;
如果你是宝塔面板的话我们打开NGINX的运行环境软件,则可以在Nginx软件管理,Nginx设置的配置栏中直接点配置修改,然后在http{(大概58行左右的位置)后复制粘贴如下两行代码即可:
支持的CDN服务商
可以兼容市面上的各大厂商的CDN产品有以下几种:
七牛云, 百度云加速, 百度开放云,腾讯云, 阿里云, 万根网络, 上海逸云, 世纪互联, 九曲网科, 云帆加速, 云盾科技, 云端智度, 云端网络, 京东云, 今科科技, 创世云, 加速乐(知道创宇), 动力在线, 华为云, 华夏名网, 华数世纪, 厦门翼讯, 又拍云, 天互数据, 天翼云, 安全宝, 安恒信息, 帝恩思科技, 帝联科技, 广州凡科, 快网科技, 新网互联, 新网数码, 易名中国, 景安网络, 智卓安全, 深信服科技, 牛盾, 白山云, 盛大云, 网宿科技, 网快科技, 美团云, 美橙互联, 聚网优速, 萤火云计算, 蓝云科技, 蓝汛科技, 蓝盾, 西部数码, 视界云, 速必拓, 速网科技, 速致, 金山云, 铱迅信息, 青松云安全, 风云互联, 首途CDN, 魔门云,15CDN, 360, 360网站卫士, AKAMAI, Adobe, Akamai, Amazon, Boreus, CDN.NET, CDN77, CDNetworks, CacheFly, Cedexis, Citrix Systems, CloudFlare, Cloudways, DIY Content Delivery Network, DNSPod, DNS盾, Distil, EDONG, EdgeCast, EuroDNS, Fastly, G-Core Labs, GOSUN(高升科技), Google, HEROKU, HIGHWINDS, IPTP Networks, ISPRIME, Incapsula, Instart Logic, Investis, KINX, KeyCDN, LEVEL3, MaxCDN, Microsoft Azure, NameBright, OVH, Omega, Oracle, PANTHEON, Planisys, Rackspace, Reblaze, ReflectedNetworks, Salesforce, Section.io, Secure Sky Technology, SpeedyCloud, Symantec, TAN14, TXNetworks, Ucloud, VOLUUM, WAFCDN, WebLuker, ZENEDGE, dediserve, online.net。
评论(2)
非常实用,非常感谢,已经完美解决问题,已经打赏站长!!
Bwer Company is a top supplier of weighbridge truck scales in Iraq, providing a complete range of solutions for accurate vehicle load measurement. Their services cover every aspect of truck scales, from truck scale installation and maintenance to calibration and repair. Bwer Company offers commercial truck scales, industrial truck scales, and axle weighbridge systems, tailored to meet the demands of heavy-duty applications. Bwer Company’s electronic truck scales and digital truck scales incorporate advanced technology, ensuring precise and reliable measurements. Their heavy-duty truck scales are engineered for rugged environments, making them suitable for industries such as logistics, agriculture, and construction. Whether you’re looking for truck scales for sale, rental, or lease, Bwer Company provides flexible options to match your needs, including truck scale parts, accessories, and software for enhanced performance. As trusted truck scale manufacturers, Bwer Company offers certified truck scale calibration services, ensuring compliance with industry standards. Their services include truck scale inspection, certification, and repair services, supporting the long-term reliability of your truck scale systems. With a team of experts, Bwer Company ensures seamless truck scale installation and maintenance, keeping your operations running smoothly. For more information on truck scale prices, installation costs, or to learn about their range of weighbridge truck scales and other products, visit Bwer Company’s website at bwerpipes.com.