php - 代理后面的 CodeIgniter session

标签 php database codeigniter session proxy

如果您没有代理 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/

相关文章:

codeigniter - PyroCMS 语言支持

php - 搜索拥有超过300万条记录的mysql数据库

php - MySQL 查询在 phpMyAdmin 中有效,在 PHP 中失败

javascript - Facebox 插件 onClick 做某事

mysql - 如何创建一个包含季度和本季度未订购客户的表 - MySQL?

mysql - 将.db文件导入到mySQL

php - CodeIgniter 中的 URI 路由

javascript - 使用 jQuery、ajax 和 php 创建动态内容。但是我的导航栏不起作用

php - SQLSTATE[HY000] : General error: 1 table posts has no column named *

php - 在 PhpWord 中创建表格