How to return HTTP status code 404 with Nginx and AngularJS

I have an AngularJS front-end running in an nginx server. The angular webapp is sending requests to a Rails API running in a Puma server.

I have developed in AngularJS side a custom 404 page to serve not found pages. In my app.js that is handling routing, I have:

$routeProvider.otherwise({templateUrl: 'partials/404.html', controller: '404Ctrl'});

From user point of view is working great. However, the HTTP status code is still 200 instead 404.
Some people say this is right, but I need to return status 404 to notify Google to remove many old indexed pages.

How can I do it? I have post all my architecture just in case there is a solution involved in the rails api server side.

Source: New feed
Source Url How to return HTTP status code 404 with Nginx and AngularJS