theforeman/foreman — pull request #757 by eLobato (2013-07-01 12:28:37+00:00)
Title: Remote addr can support several load balancers

Shortly after two load balancers were set up for our foreman installation, we noticed sometimes calls to /unattended/built were failing. This was due to this line of code in UnattendedController,

```ruby
if request.env['HTTP_X_FORWARDED_FOR'].present? and (ip =~ Regexp.new(Setting[:remote_addr]))
ip = request.env['HTTP_X_FORWARDED_FOR']
end
```

Since I thought :remote_addr was just an IP, this IP was set to one of the balancers. Of course in a system with several load balancers, some calls would fail. :remote_addr could be an array that contains several ips, but I believe that since it's a string used as a regexp, we can exploit this fact to support several load balancers. It works.