Anthony
Anthony

Reputation: 35928

How to host angularjs1 app on nginx that hosts other applications

I have an angularjs one application in a dist folder. I would like to host it on my nginx. My nginx currently hosts multiple applications via proxy_pass. I've never hosted a static html app on nginx so I'm not sure what to do.

I've created a new file at /etc/nginx/sites-available/locations/mystatic.conf and placed the following content in it:

location /mystatic {
        try_files $uri $uri/ /home/anthony/dist/index.html;
}

But after restarting nginx and going to http://<myserver>/mystatic I get a 404.

Upvotes: 0

Views: 61

Answers (1)

Faisal Memon
Faisal Memon

Reputation: 1107

Try:

location /mystatic {
    index index.html;
    alias /home/anthony/dist;
}

Upvotes: 1

Related Questions