: Mirror website across different hosting accounts Is it possible to mirror a website across different hosting accounts, for example: exampleA.com (public) exampleB.com (private) When people access
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).
More posts by @Hamaas447
3 Comments
Sorted by latest first Latest Oldest Best
You can do this in nginx by using the reverse proxy option, something like this will work:
server {
listen 80;
server_name exampleA.com exampleA.com; location / {
proxy_pass 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.
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 / exampleB.com/ ProxyPassReverse / exampleB.com/ </VirtualHost>
Proxy directives can also added in the .htaccess file or triggered via mod_rewrite using the [P] (for proxy) flag.
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.