Sulman Baig Sulman Baig - 2 months ago 25
AngularJS Question

How to deploy AngularJS static app Rails 5 api full separate on same droplet?

I have a Rails 5 API fully separate with capistrano. I have a ubuntu droplet on Digital Ocean and its running Rails 5 API deployed with capistrano, nginx, passenger phussion, postgresql.

I have a separate Angular front static website which will be dropped in AWS s3. Due to latency issue and pricing, I want both app front and back end on same droplet. Is it possible? If yes how to do that?

Answer

You can set a second server block on nginx to your Angular project. Copy and edit the default configuration file in /etc/nginx/sites-available/default,

sudo cp /etc/nginx/sites-available/default /etc/nginx/sites-available/angular_project

Point it to the folder containing your front end and set your domain name:

server {
    ...
    root angular/project/path;
    server_name frontend.domain.name.com; 
    ...
}

Then enable the server block:

sudo ln -s /etc/nginx/sites-available/angular_project /etc/nginx/sites-enabled/

And restart the ngingx service

sudo service nginx restart