如果您没有代理 IP 列表会怎样?使用 Akamai、Google、Edgecast 或 CloudFront 等站点加速服务时;从他们那里获取 session 的 IP 总是很困难。
在 CDN 上测试我们的 codeigniter 应用程序时,我们注意到 IP 作为 CDN IP 而不是 session 数据库中的客户端 IP 传递。
你怎么能解决这个问题?
/*
|--------------------------------------------------------------------------
| Reverse Proxy IPs
|--------------------------------------------------------------------------
|
| If your server is behind a reverse proxy, you must whitelist the proxy IP
| addresses from which CodeIgniter should trust the HTTP_X_FORWARDED_FOR
| header in order to properly identify the visitor's IP address.
| Comma-delimited, e.g. '10.0.1.200,10.0.1.201'
|
*/
$config['proxy_ips'] = '';
谢谢!
最佳答案
根据您使用的 Web 服务器,有一些模块可以从 HTTP_X_FORWARDED_FOR header 或您的代理的等效项中为您提供真实的客户端 IP 地址。
我在 CloudFlare 后面的网络服务器上使用 Nginx,所以我使用这个:http://wiki.nginx.org/HttpRealipModule
您需要为您的网络服务器配置模块,以便从您的 CDN 的正确 header 中获取真实的客户端 IP。
关于php - 代理后面的 CodeIgniter session ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11963641/