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).

  • 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. – barrycarter Nov 8 '14 at 16:10
  • @barrycarter Thanks for your comment. What I mean is live mirroring. Is there any possible to do it? – user1995781 Nov 8 '14 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? – barrycarter Nov 8 '14 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 '14 at 16:40
3

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

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.

2

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.

  • Thanks for your answer. How can it be done on IIS 7? – user1995781 Feb 17 '15 at 9:18
  • Here is a guide to doing so with IIS: blogs.iis.net/carlosag/archive/2010/04/01/… – Stephen Ostermiller Feb 17 '15 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? – user1995781 Feb 18 '15 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. – Stephen Ostermiller Feb 18 '15 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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