Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite Question on Consolidating Subdomains

Apache Mod_Rewrite Subdomains

         

dmcknig208

4:20 am on Jul 16, 2010 (gmt 0)

10+ Year Member



I have spent a good chunk of today searching for someone trying to do what we're attempting, and haven't come across anything that matches. We have three domains that look something like this, each on a different server:

domain.com (home page and Joomla content on LAMP)
ecommerce1.domain.com (proprietary app #1 on IIS server #1)
ecommerce2.domain.com (proprietary app #2 on IIS server #2)

We'd like to consolidate everything under the primary domain instead of linking off to the sumdomains on different servers. But because the proprietary ecommerce apps are running on IIS, we're stumped.

Is there a way to use Mod_Rewrite to direct traffic out to the IIS servers without the visitor feeling like they're being moved to the subdomain? Can we do a rewrite that would make it appear in the address bar that the visitor is still on domain.com rather than the subdomain they're actually on?

Such as URL of h t t p://domain.com/ecommerce1 actually says that in the address bar,
but in reality redirects to h t t p://ecommerce1.domain.com (which is on an external server and not just another directory off the root of domain.com -- and as noted, not another Apache server)?

Also, any thoughts on potentially rewriting the links on the subdomains on IIS to point to the primary domain rather than the subdomain so everything comes into the Apache server to manage the consolidation. Look and feel of the site is consistent across all three domains. We don't want to do this with frames. We believe the current primary + two subs is hurting us on SEO.

Any other thoughts or ideas? Thanks!

jdMorgan

1:02 am on Jul 17, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a typical application for a reverse proxy. See Apache mod_proxy for more info.

Note that implementing a reverse proxy makes all traffic pass through the Apache server, which in addition to your home page and Joomla page traffic, will now forward all client requests to the two IIS servers. It will also accept responses from those two IIS servers and send them back to the client.

In addition to the increased traffic, the client requests that are proxied will be logged on the Apache server. The IIS servers will see all incoming traffic as originating at the Apache server, and will no longer 'see' the original client IP addresses.

In order to get around this, it is customary to configure the front-end (Apache server) to NOT log the forwarded requests, and also to send along the HTTP X-Forwarded-For header, containing the original requestor's IP address. The value in this header should then be logged by the back-end servers, rather than logging the Remote_Host value as they did before.

Again, all of this is covered more thoroughly in the Apache mod_proxy documentation, and I commend it to you.

Jim

dmcknig208

3:58 am on Jul 17, 2010 (gmt 0)

10+ Year Member



Thanks for the info. We'll take a look at mod_proxy.