Redirect_to for Nginx Reverse Proxy?

I’m trying to figure out the best way to do this. I’m working on a web
application where the entire thing requires the user to be logged in. I
use a before_filter in all the controllers to check for the logged in
session variable. If it doesn’t exist, I redirect to the “login”
controller and the “index” action.

We’re planning on rolling out this web app to multiple clients soon so
I’m planning on putting multiple servers behind an Nginx reverse proxy.
So, for example, when the user goes to:

It accesses a server that serves site1 (i.e.
without the site1). Another server will serve site2.

Problem is - if the user isn’t logged in it makes the call to:

redirect_to :controller => “login”, :action => “index”

This works fine in a single server configuration - but in this case it
redirects the browser to:

What’s the best way to handle this kind of situation? Will there be any
issues with session variables in this type of reverse proxy situation?