where does this IP come from in the log

On the rails production log I am getting this in the log file

To expand on that, if you are using mongrel behind nginx, apache etc... then all the requests to the mongrel come from nginx/apache (ie from localhost). The webserver needs to set the right headers so that it can pass on what it knows to rails.

Fred

Hi, After I sent this I realized that this issue was probably caused by the lighttpd server sending the requests to the mongrel cluster. So what header should I be looking for on lighttpd. Any suggestions would be appreciated.

atlantageek wrote:

After I sent this I realized that this issue was probably caused by the lighttpd server sending the requests to the mongrel cluster. So what header should I be looking for on lighttpd. Any suggestions would be appreciated.

Have a look at the definition of #remote_ip in .../gems/actionpack-x.y.z/lib/action_controller/request.rb

You'll see it tries to use HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR and REMOTE_ADDR in that order. To see what your Rails app is getting, try adding this to one of your views:

<%= debug request.env %>

I don't know anything really about lighttpd so don't know what you can trace there, but you could sniff the network packets from the browser and look at the request header that way. Compare with the above Rails to see what is being added by lighttpd. Of course, some of this will be updated by mongrel, too, so to complete the picture you'd need to look at the headers going between lighttpd and mongrel.

If you are only ever seeing 127.0.0.1 in the headers in Rails, then it suggests lighttpd is not adding the remote IP address so mongrel things the request originates from lighttpd.