Nginx configuration for Angular

Written by Yujin Boby

Edit in WordPress

Angular is a single-page application (SPA) framework. To serve Angular application using Nginx web server, use following configuration.

server {
    listen *:80;
    root /var/www/html;
    index index.html;
    location / {
        try_files $uri$args $uri$args/ /index.html;
    }
}

You can build static files using the command

ng build

Upload the static files it builds, usually in the dist folder to document the root of your website, in this case, /var/www/html

Back to Nginx