Logging external ip behind reverse proxy

I have a instance of ownCloud 9.1.0 (stable), and I'm trying to set up fail2ban. The problem is that the owncloud log has my reverse proxy ip not the external ip. I'm using a NGINX reverse proxy which has "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;" set in the the config. I have also added " 'forwarded_for_headers' => array('HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR')," in config.php. Any help would be greatly appreciaated. 


have a look at this comment for some pointers:

Thanks for the help, I had come across that post before but obviously didn't read it close enough. For those who may find this post this is what I implemented.


proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

In owncloud config.php

'trusted_proxies' => array ('IP of proxy'),
  'forwarded_for_headers' => array('HTTP_X_FORWARDED_FOR', 'HTTP_FORWARDED_FOR'),