Can you have the same domain name on two different servers distinguished only by a folder name
Solution 1
As Jenny said, this is not generally possible. However, you could add a reverse proxy in front of your setup and map two external servers to two directories on your front end domain. Note that this is not necessarily possible for all web apps and might potentially increase latencies.
Solution 2
Of course it possible, CDN-services or large sites can use this way.
Example for nginx:
location /publicstuff/ {
root /var/www;
}
location /privatestuff/ {
proxy_pass http://192.168.0.2;
}
Users vision: www.domain.com/publicstuff/ and www.domain.com/privatestuff/ are identical, but all queries to privatestuff are proxying to another server.
Related videos on Youtube
djack109
I write code, clean clear and simple. Problem, no problem if there is a solution I will find it.
Updated on September 18, 2022Comments
-
djack109 almost 2 years
Is it possible to have the same domain across two different servers distinguished by just a folder name.
E.g.
Server 1 www.domain.com/publicstuff
Server 2 www.domain.com/privatestuff
Other considerations.
- The servers might not be on the same IP range,
- The servers might not be in the same physical location
- The servers will be using different web technologies and hosts
- Drupal/Apache, Webforms/MVC/IIS
-
Jenny D almost 7 yearsNo, it's not. That is not how domain names work.
-
djack109 almost 7 yearsI thought not but thought I would ask the wider community.
-
ceejayoz almost 7 years@JennyD It's not how domain names work, but that doesn't mean it's not possible. This is something you could set up with AWS Cloudfront, for example, using it's ability to have multiple origins for a single distribution.
-
Jenny D almost 7 yearsYou are right of course, @ceejayoz - I was wrong to focus only on the DNS side of things. Thanks for correcting me!
-
aaaaa says reinstate Monica almost 7 yearswhat is the problem you are trying to solve?
-
David W almost 7 yearsYou could setup a subdomain for each site. So instead of domain.com/publicstuff, you could do publicstuff.domain.com, and privatestuff.domain.com.
-
djack109 almost 7 years@DavidW I've already gone with this solution.@aaaaaa there isn't a problem to solve. I was asked if we could do this by my PM and after a short time in thought I said no, but it did get me thinking hence the question. As there isn't a quick easy response looks like I made the right choice
-
djack109 almost 7 yearsWhy the down-vote ? It was a perfectly fair and reasonable question.
-
djack109 almost 7 yearsThanks All. I said it wasn't a good idea so thanks for the back up