Is it possible to use one domain for two Rails projects on two different droplets?
I have two droplets (DigitaOcean) with two different Rails 5 projects (ubuntu 18, nginx, puma). One for the website and another for API (backend for mobile app).
I mean that I want to buy example.com
domain. After that, I want to use example.com
for website and api.example.com
for API.
I think that I should make some work with nginx config? Should I use private IP? Which droplet should process traffic depending on url?
You don't have to worry about nginx config, domain handling or smth else by the server. All you need to do in this case is create 2 droplets: website droplet with IP 1 API droplet with IP2
then in your DNS manager (DigitalOcean or somewhere else where your nameservers are pointing) add A records:
example.com to IP1
(optional) www.example.com CNAME to example.com
api.example.com to IP2
No smart or complex configuration needed :)