Two Rails projects on two different droplets with single domain

March 6, 2019 352 views
Ruby on Rails Nginx

Is it possible to use one domain for two Rails projects on two different droplets?
I have two droplets 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 domain. After that, I want to use for website and 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?

1 Answer
pjha March 6, 2019
Accepted Answer

That’s certainly feasible.

Make Sure resolves to the intended Droplet and Nginx has virtual hosts configured to handle requests for this subdomain. Same applies to Main domain on the other Droplet.

Private IPs aren’t required if you are looking to use a domain and subdomain hosted on separate droplets. Let me know if you have any further questions.

  • If I understood correctly, I should use both Droplets independent with separate nginx config on each droplet. Just use DNS for a subdomain like here?

Have another answer? Share your knowledge.