代理后的CodeIgniter会话 [英] CodeIgniter session behind proxy

查看:199
本文介绍了代理后的CodeIgniter会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您没有代理IP列表时会发生什么?当使用网站加速服务,如Akamai,Google,Edgecast或CloudFront;

What happens when you don't have a list of proxy IPs? When using site acceleration services like Akamai, Google, Edgecast or CloudFront; it would always be hard to get IPs for sessions from them.

在CDN上测试我们的codeigniter应用程序时,我们注意到IP是作为CDN IP传递的,而不是

When testing our codeigniter application on a CDN, we noticed that IPs were being passed as CDN IPs and not the client IPs in the session database.

如何解决这个问题?

    /*
|--------------------------------------------------------------------------
| 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'] = '';


$ b

谢谢!

Thanks!

推荐答案

根据您使用的网络服务器,有一些模块可以从HTTP_X_FORWARDED_FOR标头或您的代理的等效端口获得真正的客户端IP地址。

Depending on the web server you use there are modules that will give you the true client IP address from the HTTP_X_FORWARDED_FOR header, or the equivalent for your proxy.

我在我的web服务器上使用Nginx CloudFlare后面,所以我使用这个: http://wiki.nginx.org/HttpRealipModule

I use Nginx on my web server behind CloudFlare so I use this: http://wiki.nginx.org/HttpRealipModule

您需要为您的网络服务器配置模块,以从CDN的正确标头获取真实的客户端IP。

You'll need to configure the module for your web server that gets the real client IP from the correct header from your CDN.

这篇关于代理后的CodeIgniter会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆