So I created a reverse proxy on the abc.com server where xyz.com/users/sign_in will proxy for "/users/sign_in" so that in url it would show abc.com/users/sign_in. And that worked fine in ubuntu and apache2. After enabling proxy in ubuntu, I set my virtual host like this:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName abc.com
ServerAlias www.abc.com
DocumentRoot /var/www/vhosts/abc.com/public_html
<Directory /var/www/vhosts/abc.com/public_html/>
Options FollowSymLinks MultiViews
AllowOverride All
</Directory>
ProxyRequests Off
<Proxy *>
Order deny,allow
Deny from all
Allow from all
</Proxy>
ProxyPass /users/sign_in http://xyz.com/users/sign_in
ProxyPassReverse /users/sign_in http://xyz.com/users/sign_in
ErrorLog /var/log/apache2/abc.com-error.log
LogLevel warn
CustomLog /var/log/apache2/abc.com-access.log combined
</VirtualHost>
Now here's the problem. /users/sign_in does a post request on the other server (the xyz server), that is, its an actual form that gets submitted, and the code on the other server redirects the user to the root of the website. Here's the log from the other server:
Started POST "/users/sign_in" for IPADDRESS at 2012-02-22 14:59:13 -0500
Processing by Users::SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "remote"=>"true", "commit"=>"Login", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "subdomain"=>"", "remember_me"=>"0"}}
Redirected to http://abc.com/
Completed 302 Found in 110ms
So this is actually good it appears on the surface. The other server responded, signed the user in and then redirects them to the root url. The problem is they dont get redirected to the root url: xyz.com (which contains the application code i want them to see). Rather they get redirected to abc.com which is the other server.
But if I add a proxy for xyz.com in addition to xyz.com/users/sign_in in the abc.com server, then I will have a big problem. How will the browser know whent the user wants to see abc.com (the actual site content) and xyz.com (the application that I want to load after the /users/sign_in is invoked).
I am completely stuck on this and open to any suggestions.
Hmm - interesting deployment give this a shot. This will proxy all requests to the
xyz
server if the client sends a_session_id
cookie.Put it below your existing
ProxyPassReverse
configuration; the order is significant for theProxyPass
directives.This seems pretty fragile - I'm sure you have a reason for doing it like this, but is there no other way to separate the authenticated and unauthenticated sections of this application?
Edit: To have the
xyz
content served from/tracking
instead: