3

I have Server A which hosts www.mysite.com

I want to create and host a site on Server B, but configure it to: www.mysite.com/theSiteAtServerB

TheSiteAtServerB is a completely different site from www.mysite.com and is on a completely different server but the client wants to use www.mysite.com and serve the content for TheSiteServerB under the same url.

Is this at all possible? DNS configuration? or through some Apache magic?

Thank you!

EDIT 1:

To clarify, I would like to achieve this without redirecting or rewriting urls.

http://www.mysite.com/ & http://www.mysite.com/siteAtServerB are separate sites >techinically with different IP addresses I wanted to know if its possible to modify DNS so that I can point www.mysite.com --------------> ServerA (currently) www.mysite.com/theSiteAtServerB --------------> ServerB


EDIT 2** To make sure I understand the flow, would it work like this:

1- Web Request comes into Server A

2- mod_rewrite processes the request against the matched rule

3- mod_proxy fetches content from the origin server and returns it back up to the response

In terms of security, would most of the locking down come from just nailing the regex >expression for mod_proxy? Based on this: http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#access, I'd assume that >I'll also need to set the proxy access? But if the site is a public site, what would I put >in the Proxy access block, would I set it to allow *

1
  • What you're doing is setting up a forward proxy. Unfortunately, the setup I had that did just this went away 2 years ago and my notes are one job old so, er, not that useful. The proxy access MAY just be 'localhost' since it's the webserver originating it. Alternately, you can lock out the proxy HTTP verbs (CONNECT) which does much the same thing.
    – sysadmin1138
    May 8, 2012 at 2:17

3 Answers 3

6

What you're trying to accomplish is doable through the use of mod_proxy, which is not commonly enabled for shared-hosting environments because of the rather significant security problems it can allow if not locked down right. If you don't do it right, you'll provide an open proxy for nefarious people to surf the internet using the server's IP address.

If you have complete access to the web-server you can turn mod_proxy on. This uses mod_rewrite to set up the correct proxy:

RewriteRule ^/SiteAtServerB/(.*)      http://serverb/site/$1     [P,L]

The more precise of a regex you can provide, the better protected you are from nefarious business.

This will do exactly what you're looking for. ServerB will see a request coming from ServerA's IP address (one of them, anyway), clients will just see a URL that doesn't change.

1
  • comment came out ugly, see edit above
    – willz
    May 7, 2012 at 23:37
0

"Apache magic" would mean redirection.

Or, as also suggested here, proxying.

The client computer will only ask DNS about the domain name without any other parts of the URL having a bearing on what it asks (technically, SRV records could be involved, but these would be queried based on information LEFT of the domain name!). So DNS CAN NOT know where to send you.

If you want to learn the details, might I suggest you setup wireshark, start capture, open a web browser and any site in it you haven't visited for a while, stop capture, and look at how things work behind the scenes...

0

You may be able to do this with a global load balancer (so mysite.com resolves to the LB which then redirects to serverA or serverB as appropriate) subject to your budget and infrastructure, and your hosting provider(s) can probably help with this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .