Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a legacy system that I'm attempting to make a significant configuration change to, but am not seeing a way to do so cleanly.

The state I inherited consists of a web site hosted on two app servers which sit behind a load balancer ( each server hosts a LAMP stack). The A record (example.com) for the domain points to the balancer, as does the CNAME entry for 'www.'

Now, I'd like to move this site to another server that I have set up and ready to go, something that would normally be quite simple; however, the problem that I have is that the servers that currently serve the website also serve additional applications served from sub-directories on the same 'example.com' and 'www.example.com' entries.

What I desire is as follows:
   www.example.com and example.com point to server A
   www.example.com/scripts... and example.com/scripts... point to the current load balancer

This would have been simple were the services originally set up in sub-domains, but that is not so and making the migration would be quite painful for a significant number of clients.

I can't find an elegant way of doing this. Does anyone have any suggestions?


Update:

To clarify, the products in the /scripts/... directory are accessed programmatically over an SSL connection by client-built applications (it's a service that takes in a query string and returns XML). Does this have an effect on the solution?

share|improve this question
1  
You'll need to proxy stuff. –  ceejayoz Dec 8 '11 at 17:14
add comment

3 Answers

Can you not set up a subdomain for the main app? Something like www2.example.com (or remove subdomains altogether and have it on just example.com), then just put a redirection from the site root to the new subdomain? If you do the redirection using .htaccess you can redirect everythhing except /scripts to the new server.

The .htaccess file would look something like this:
RewriteEngine on
RewriteCond $1 !^scripts
RewriteRule (.*) http://www2.example.com/$1 [R=301,L]

The 301 code above specifies the redirection is permanent; search engines will like this, if you're worried about losing ranking. Also, this code should redirect users to the equivalent page on the new URL so bookmarks and other links to pages on the old URL still work. (Test it first though)

share|improve this answer
    
Or the contrary - redirect /scripts from new main site to old load balancers. –  Sandman4 Dec 8 '11 at 18:41
    
Yes, or that! Only the scripts would then be at the mercy of server A to stay up, so you may lose some redundancy, depending on what the load balancers are there for, and what the new setup will be. –  Demelziraptor Dec 9 '11 at 11:38
add comment

Yeah - a bit of a pickle. For a long-run solution you should probably work towards moving the other apps to their own sites. For a temporary workaround you would use a redirect on either the load balancer or the original LAMP servers to the new site until you can change the www record.

share|improve this answer
    
This is not my area of specialty, unfortunately, so am a bit on the unknowledgeable side of things here. Is there a straightforward way to redirect all traffic EXCEPT for that destined for the example.com/scripts/... directories? –  user103557 Dec 8 '11 at 17:48
    
I have no idea on your balancer but if you want info on how to actually do this in Apache- look here. You will basically redirect those intended to hit the root website. The content in the other directories will remain accessible directly. –  Paul Ackerman Dec 8 '11 at 18:06
    
Our balancer is not capable of performing the redirects, unfortunately. So I will look into the apache redirects. –  user103557 Dec 8 '11 at 20:36
add comment

Set up reverse proxy on NewServer, which will make all requests to a certain URL/URI be forwarded to your OldServer.

Obviously, you'll have to set up a separate domain for the old server, but this maintains the URL's.

http://httpd.apache.org/docs/2.0/mod/mod_proxy.html

<Location /legacy-app/>
    ProxyPass http://oldserver.example.com/legacy-app/
    SetEnv force-proxy-request-1.0 1
    SetEnv proxy-nokeepalive 1
</Location>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.