3

Is it possible to mirror a website across different hosting accounts, for example:

  • exampleA.com (public)
  • exampleB.com (private)

When people access the website they will be visiting exampleA.com but everything that is requested will be coming from the private site (exampleB.com).

4
  • Do you mean live mirroring or mirroring at specific times? If you just need to mirror files, you might look at github.com/barrycarter/bcapps/blob/master/bc-mirror-server.pl which is how I maintain my website. I store it locally on my computer and mirror after making changes.
    – user3919
    Nov 8, 2014 at 16:10
  • @barrycarter Thanks for your comment. What I mean is live mirroring. Is there any possible to do it? Nov 8, 2014 at 16:17
  • What sort of changes will occur on private.com? You can always edit and instantly mirror, but is there more going on? Will public.com also be changing? For example, will people be posting comments or writing articles on public.com? If so, should these comments/articles be wiped out when you mirror?
    – user3919
    Nov 8, 2014 at 16:24
  • I used to work for a global telecom and we would mirror some internal sites to public sites, but did not generally do this in real-time for quality assurance reasons. It could have easily been real-time however with the flip of a switch. In our case, a user acceptance test (UAT) group would review the changes and trigger the update instantly if approved. These could be triggers for an rsync (file sync) process or a database sync process depending upon the sites requirements.
    – closetnoc
    Nov 8, 2014 at 16:40

3 Answers 3

4

You can do this in nginx by using the reverse proxy option, something like this will work:

server {
    listen 80;
    server_name exampleA.com www.exampleA.com;
    location / {
        proxy_pass http://exampleB.com;
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host $server_name;
    }
}

The above code will effectively serve everything that's on exampleB.com but actually the user will be browsing the site using the public domain exampleA.com.

3

Apache supports this feature, its called a reverse proxy. It will work whether or not the sites are served from the same server or not.

One way to do so would be to use mod_proxy with the Apache webserver. The configuration of the virtual host for public would look like this:

<VirtualHost *:*>
    ServerName exampleA.com
    ProxyPass / http://exampleB.com/
    ProxyPassReverse / http://exampleB.com/
</VirtualHost>

Proxy directives can also added in the .htaccess file or triggered via mod_rewrite using the [P] (for proxy) flag.

4
  • Thanks for your answer. How can it be done on IIS 7? Feb 17, 2015 at 9:18
  • Here is a guide to doing so with IIS: blogs.iis.net/carlosag/archive/2010/04/01/… Feb 17, 2015 at 12:41
  • I have tried, but it seems like redirect to the URL. I was trying to get help from hosting company and this is the reply from them ask your domain provider to assist you to create the Url masking. What is URL masking? Is that mean I need to set url masking at private.com in order for it to works? Feb 18, 2015 at 15:38
  • A URL mask is also called a "framed redirect". It doesn't actually mirror the website. See this question for more information about how they work. Feb 18, 2015 at 15:41
3

If you are on the same server, then set the document root for exampleA.com to the same document root as exampleB.com.

Example:

  • Point them both to /the/path/to/hosting/folder

They should then show exactly the same content.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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