• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Feature Requests (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Right IP address in rev-proxy environment

This forum is now locked as we will no longer be developing the v1.x branch

Moderators: OldWolf, re*s.t.a.r.s.*2

Topic locked
6 posts • Page 1 of 1

Postby arturm » Fri Mar 16, 2007 9:24 pm

When http server is behind rev-proxy, then IP address point to rev-proxy IP, not real user IP. I propose add small hack:
In /src/commands/connect.class.php after line:

// store the user ip

add lines:

// by AM: adding proxy logging
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
if (empty($ip)) {
$ip = $_SERVER["REMOTE_ADDR"];
}

Now Admin see real user IP.
arturm
New member
 
Posts: 7
Joined: Mon Mar 12, 2007 9:11 pm
Top

Postby phpfreechat » Tue Mar 20, 2007 9:48 am

Thank you it's integrated in 1003 revision.
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby datacompboy » Thu Mar 29, 2007 10:30 am

2 arturm: you should install in apache mod_rpaf and you will get correct info in all scripts.

2 kerphi: that _BAD_ idea to use any headers except of REMOTE_ADDR, or add configuration param, that _should_ be disabled by default. Since now I can just spoof my IP on any chat just by adding HTTP_X_FORWARDED_FOR on mine proxy :)
-- suicide proc nearn call deathn suicide endp
datacompboy
Member
 
Posts: 74
Joined: Thu Jan 18, 2007 9:10 pm
Location: Novosibirsk
  • Website
  • ICQ
Top

Postby phpfreechat » Sun Apr 01, 2007 12:03 pm

Thank you datacompboy for your suggestion.
I just applied this patch :
Code: Select all
Modified: trunk/src/commands/connect.class.php
===================================================================
--- trunk/src/commands/connect.class.php        2007-03-29 08:29:05 UTC (rev 1011)
+++ trunk/src/commands/connect.class.php        2007-04-01 11:01:46 UTC (rev 1012)
@@ -43,7 +43,9 @@
    $nickid = $u->nickid;
    $ct->joinChan($nickid, NULL); // join the server
    // store the user ip
-    $ip = isset($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];
+    $ip = ( $c->get_ip_from_xforwardedfor && isset($_SERVER["HTTP_X_FORWARDED_FOR"])) ?
+      $_SERVER["HTTP_X_FORWARDED_FOR"] :
+      $_SERVER["REMOTE_ADDR"];
    if ($ip == "::1") $ip = "127.0.0.1"; // fix for konqueror & localhost
    $ct->setUserMeta($nickid, 'ip', $ip);
    // store the admin flag

Modified: trunk/src/pfcglobalconfig.class.php
===================================================================
--- trunk/src/pfcglobalconfig.class.php 2007-03-29 08:29:05 UTC (rev 1011)
+++ trunk/src/pfcglobalconfig.class.php 2007-04-01 11:01:46 UTC (rev 1012)
@@ -131,6 +131,14 @@
  var $debugurl            = "";
  var $debug               = false;
  var $debugxajax          = false;
+
+  /**
+   * This parameter is useful when your chat server is behind a reverse proxy that
+   * forward client ip address in HTTP_X_FORWARDED_FOR http header.
+   * see : http://www.phpfreechat.net/forum/viewtopic.php?id=1344
+   */
+  var $get_ip_from_xforwardedfor = false;
+

  // private parameters
  var $_sys_proxies         = array("lock", "checktimeout", "checknickchange", "auth", "noflood", "censor", "log");
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby arturm » Mon Apr 16, 2007 2:57 am

Thanks, that patch is useful if chat is installed on server without mod_rpaf and user cannot install any mod.
arturm
New member
 
Posts: 7
Joined: Mon Mar 12, 2007 9:11 pm
Top

Postby danielrigano » Sun Feb 24, 2008 3:20 pm

Great tip!
danielrigano
New member
 
Posts: 1
Joined: Sun Feb 24, 2008 3:16 pm
  • Website
Top


Topic locked
6 posts • Page 1 of 1

Return to Feature Requests (v1.x)

Who is online

Users browsing this forum: No registered users and 3 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub