Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use real IP in session driver if you're behind a proxy #4471

Closed
wants to merge 2 commits into from

Conversation

remiheens
Copy link

Hi,

I'm working on a login library using memcache with CI, but I've discovered that each session driver use "$_SERVER['REMOTE_ADDR']" to prefix the session key.
But if you're running Codeigniter behind a proxy, $_SERVER['REMOTE_ADDR'] is always 127.0.0.1, and the driver doesn't use configured proxy_ips to get real client ip and the sess_match_ip option doesn't work.

So, I submit my little contribution to Codeigniter :)

Remi Heens added 2 commits February 18, 2016 15:02
Signed-off-by: Remi Heens <remi.heens@gmail.com>
Signed-off-by: Remi Heens <remi.heens@gmail.com>
@narfbg
Copy link
Contributor

narfbg commented Feb 18, 2016

Duplicate of #4003.

@narfbg narfbg closed this Feb 18, 2016
@remiheens
Copy link
Author

Ok, but what is your solution ?

@narfbg
Copy link
Contributor

narfbg commented Feb 18, 2016

I don't have a specific solution, but that's irrelevant - as far as I and CodeIgniter are concerned, trusting a client-provided IP address is a security flaw and not an option.

It's up to you to come up with another solution for whatever you're trying to do.

@remiheens
Copy link
Author

Ok, I understand ;)

But it's my nginx configuration who forward the query on apache/php by proxy_pass and client ip was added to HTTP Header with this configuration :

proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

Do you think it's a security flaw ?

@narfbg
Copy link
Contributor

narfbg commented Feb 18, 2016

You know that it's your nginx configuration and that you could trust it. The code doesn't.

@remiheens
Copy link
Author

So, in my case. I can create a subdriver of Session_memcached_driver that use real ip. Do you think it's a good alternative ?

@narfbg
Copy link
Contributor

narfbg commented Feb 18, 2016

No, but please note that this is a bug tracker ... we don't answer general help requests here.
Please ask your questions on our forums instead.

@narfbg narfbg reopened this Feb 18, 2016
@narfbg narfbg closed this Feb 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants