Can I point two different types of server on same domain

Right now I have WordPress site running on my domain via digitalocean. However, I have security issues and don't want to manage the WordPress site on digitalocean server myself.

Besides this, I also have some sites which are deployed using CI-CD and for that I need digitalocean.

I want to know, can I point the two different servers:

  1. managed hosting which has wordpress site (at root domain domain.com)
  2. Digitalocean sites (at subpath domain.com/mysubpath/other-site)

on the same domain domain.com.

This means, If I visit domain.com I should be handled by managed hosting WordPress site and if I visit domain.com/subpath/other-sites then I should be handled by digitalocean sites as WordPress site don't have such URL.

Thanks.


Solution 1:

Only indirectly – by having the "managed hosting" site receive the requests and proxy them to the appropriate server (using the reverse proxy capabilities of the web server). While the reverse-proxy feature is relatively standard, managed-hosting providers probably do not offer it.

Clients look up server addresses by their domain name only; the URL path is not used in DNS lookups, and is not sent anywhere until after the connection to the server is established.

So if the URLs use the same domain name, the requests will always end up being sent to the same destination server (where the domain's A/AAAA records point). Once the web server accepts the full HTTP request, it can proxy it elsewhere and relay the response back to you as well.

But if the URLs must directly point to different servers, then they must use different (sub)domains.