CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Getting an IP address when server behind proxy
Pages: [1]

Author Topic: Getting an IP address when server behind proxy  (Read 2032 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Getting an IP address when server behind proxy
February 07, 2011, 07:01:28 pm
Posting this here for Brian / others to comment on....

(3:31:47 PM) eileen: dlobo - I have a question. I have patched up eWay for a customer to send out extra details to eWay - for fraud detection. Anyway, works fine on our test but on live it fails because "The live server is behind a reverse proxy. If you want to send the client IP then you can get it from the X-Forwarded-For header. $real_ip = $_SERVER['X-Forwarded-For']; "
(3:32:42 PM) eileen: I'd prefer to build the bit where it gets the real IP into Core if possible rather than twist up the install
(3:34:29 PM) dlobo: eileen: check if drupal does this for u
(3:34:34 PM) dlobo: most likely it should be in there
(3:48:01 PM) eileen: dlobo - yes, you are right http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/ip_address/6 - but it is specifically drupal as you configure the proxies in settings.php for security. I don't suppose you'd be open to adding a clause in static function ipAddress( ) { which calls the drupal function if the CMS is drupal - which would give the added on drupal intelligence
(3:49:06 PM) dlobo: eileen: can u check with lcdweb and see if something similar exists for joomla
(3:51:11 PM) dlobo: or eileen: u can just use the drupal code and mirate it to the ipAddress function
(3:52:07 PM) eileen: the drupal code relies on if (variable_get('reverse_proxy', 0)
(3:52:20 PM) dlobo: might be better to use the D7 version
(3:52:20 PM) dlobo: http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/ip_address/7
(3:53:13 PM) dlobo: and eliminate reverse proxy
(3:53:25 PM) eileen: thing is it doesn't 'trust' that value unless your drupal install is configured to know it's a reverse proxy
(3:53:26 PM) dharmatech: dlobo: went to strange loop conference last year. eye opening to say the least.
(3:53:34 PM) eileen: I assume it's a security setting
(3:56:38 PM) eileen: // If an array of known reverse proxy IPs is provided, then trust // the XFF header if request really comes from one of them.
(3:57:02 PM) eileen: so, the code requires it to be configured into drupal = I don't want to bypass that
(3:58:05 PM) dlobo: eileen: chat with lcdweb and try to submit a patch that does it both for drupal and joomla
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Getting an IP address when server behind proxy
February 07, 2011, 07:37:29 pm
reverse proxies in joomla are handled by defining:
Code: [Select]
var $live_site = 'http://example.com';in the site configuration.php file. the variable is usually auto-detected. defining it in the config overrides autodetection when reverse proxies will return unexpected values (non-domain)

i don't think that file/value is something we would want CiviCRM to alter (and wouldn't necessarily be able to anyway as it can be placed in different locations). help text might be sufficient to provide information on accommodating reverse proxies
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Getting an IP address when server behind proxy
February 07, 2011, 09:34:56 pm
Yep, but given that Joomla! does define reverse proxies is there a Joomla! function to get the *real* client IP - currently if behind a proxy CiviCRM collects the proxy's IP in it's CRM_Utils_System::ipaddress function
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Getting an IP address when server behind proxy

This forum was archived on 2017-11-26.