0

first time here at Server Fault, and I apologize in advance that this domain stuff is not really my strength. Any and all suggestions are much appreciated. I am completely lost and incredibly tired!

I've inherited an incredibly convoluted system from my predecessor, and I'm trying to find a way to solve it - or I need to be told that it just isn't possible.

  • I've got an old site on ServerA (some kind of Linux distribution), with the domain SomeDomain.com
  • There is a new site sitting on ServerB (Ubuntu), with the intention of having SomeDomain.com to serve it in the future (it is replacing the old site)
  • ServerA also has a web app that is currently in use by other departments within the company (accessible at SomeDomain.com/web-app/)

The goal: To have SomeDomain.com and all extensions of this domain name (sub-domains, URL's etc.) serve the new site on ServerB. BUT, the URL SomeDomain.com/web-app/ must serve the Web App on ServerA.

The Catch: The ServerA is a shared server with a hosting company with VERY limiting restrictions in place - I cannot adjust DNS settings (apart from Name servers - but cannot set A records or anything, I have full access to ServerB to do as I wish). Therefore the web-app MUST be served from SomeDomain.com/web-app/ and not from a sub-domain or anything. These limitations make migrating the web-app from Server A to Server B rather undesirable, AND this web-app will be replaced in the near future, so it isn't worth the effort right now.

Therefore, ultimately I will want 1 domain name to resolve to Server B's IP address most of the time, but in the event that the URL is SomeDomain.com/web-app/, it should resolve to Server A's IP.

Note: The domain names don't, technically, have to resolve to one IP or another - but ultimately the URL's must stay consistent

Some things I have tried:

  • I've looked into mod_rewrite and .htaccess to try and achieve this effect, but it doesn't look like it's going to work for me - but I may have done it wrong (On Server B, I just checked if the request URI was /web-app/ and tried to serve the /web-app/ folder on Server A)
  • I do have the ability to modify the name servers on both servers
  • I am not able to make a sub domain on Server A that points back to Server A (I assume because the hosting company's servers use the URL to determine what site the serve). I figured this could be good as I'd could set an A record on Server B to point to the web app on Server A - but alas, Server A requires SomeDomain.com.

If there is any more information I can give, please let me know. I need a nudge in the right direction, ideas or a solution.

Jace
  • 135
  • 4

2 Answers2

1

There are a bunch of issues here which makes it not quite as easy as it should be.

First, I think the best way to handle this is:

  1. If you cannot change the settings on server A, leave it as www.somedomain.com.
  2. Set the fully qualified domain name on server B to www2.somedomain.com.
  3. Add use mod rewrite or whatever you like to redirect traffic from www2.somedomain.com/web-app to www.somedomain.com/web-app.

Now for the details.

The DNS servers resolve the fqdn to the ip address. They cannot help you with anything below that (such as the path). DNS requests don't even contain the request path.

On a shared server, it is almost certainly using HTTP 1.1 and name based virtual hosts. In other words, the box has one IP address, and it looks at the HOST header in the request to determine which site to serve. Ergo, if you do an IP address based redirect, Server A will just get an HTTP request to 123.123.123.123/web-app/foo, and having a gajillion sites on that server it will have no idea what to do with it.

Since your servers have different content (at least for one path), and you cannot use IP address based redirects, you will have to use different fqdn's to distinguish them.

Since the old site is probably already set up with www.somedomain.com as the ServerName and it sounds like you can't change it, your only option is to create a new server name.

Ladadadada
  • 26,337
  • 7
  • 59
  • 90
jpgeek
  • 271
  • 1
  • 3
  • Hi jpgeek. In this scenario, what would I do with my DNS settings? Should I have `www.somedomain.com` point to server B (whose fqdn will be `www2.somedomain.com`? Or do I keep it pointing at server A? Would this not mean that users would have to go to `www2.somedomain.com` to reach the new site (server B)? I'm afraid I don't fully understand this, sorry! Could you please clarify? – Jace Dec 11 '12 at 01:45
  • Hi jpgeek, I did solve this issue using the `www` subdomain and some nasty htaccess redirects on `Server A` to `Server B`. I'm not sure if this is exactly what you suggested, but your answer inspired this direction, and as there is no better answer to date, I will mark your answer as correct. Thanks for your help! – Jace Dec 12 '12 at 05:06
0

You may also consider this option:

Configure your webserver on serverB to behave as a reverse proxy that hits ServerA for the specific location /web-app/ and that loads other locations content from serverB.

The config is pretty much easy and straight forward, you will find many samples available.

m0ntassar
  • 1,263
  • 7
  • 12
  • Hi m0ntassar, this sounds great. However, I've done a bit of reading into Reverse Proxies since reading your answer as I've never done it before and from what I've read, I'm not 100% sure this will work in my case, unless I'm misunderstood (which is likely)... does this mean that `SomeDomain.com` continues to point to `ServerA` (which remains untouched throughout this process) and the `ProxyPassReverse` settings would be on `ServerB`? – Jace Dec 10 '12 at 06:07
  • ProxyPassReverse should sit on the server on which somedomain.com points. The solution i provided you supopses that you alreadey repaced site on serverA by site sitting on the new serverB – m0ntassar Dec 10 '12 at 08:20
  • Oh ok, unfortunately that won't work in this case due to the limitations of `ServerA` so I will not be able to replace the site. I must keep the contents of `ServerA` as it is, but serve all requests from `ServerB`, unless the uri is `/web-app/`. A very confusing and unfortunate situation. But thanks for the suggestion! – Jace Dec 10 '12 at 09:52