Nginx configuration for Angular

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

Need help with Linux Server or WordPress? We can help!

Leave a Reply

Your email address will not be published. Required fields are marked *