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

Advertisement

Add a comment

Leave a Reply

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

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Advertisement