Two Rails projects on two different droplets with single domain

Posted March 6, 2019 1.1k views
Ruby on RailsNginxUbuntu 18.04

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?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 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.