Codeigniter ci_sessions表将IP地址存储为0.0.0.0为什么?即使托管我也得到0.0.0.0 [英] Codeigniter ci_sessions table storing ip address as 0.0.0.0 why? even when hosted I am getting 0.0.0.0
问题描述
在我的代码编辑器中,您好,我已将表创建为ci_sessions并包含以下字段
Hello in my codeigniter I have created table as ci_sessions with following fields
CREATE TABLE IF NOT EXISTS `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);
除IP地址为每个客户端存储为0.0.0.0之外,每个字段都工作正常。我已经按如下方式编辑了config.php。
Every field is working fine, except ip address which is storing as 0.0.0.0 for every client. I have edited my config.php as below.
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'ci_sessions';
$config['sess_match_ip'] = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
推荐答案
使用Linode,您的应用可能位于代理之后。您可以找出您的代理IP并将其添加到CodeIgniter配置文件( /application/config/config.php
的底部)的白名单中,或按照上的说明进行操作。 Linode的Nodebalancer参考以供使用Apache mod_rpaf
模块将 X_FORWARDED_FOR 重映射到 REMOTE_ADDR 。
With Linode your app is likely behind a proxy. You can either find out your proxy IP and add it to the whitelist in your CodeIgniter config file (bottom of /application/config/config.php
), or follow the directions on Linode's Nodebalancer Reference for using the Apache mod_rpaf
module to remap X_FORWARDED_FOR to REMOTE_ADDR.
这篇关于Codeigniter ci_sessions表将IP地址存储为0.0.0.0为什么?即使托管我也得到0.0.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!