0

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 have my app in dist folder on the nginx server at location /home/anthony/dist.
  • My nginx configuration has only a single file in ssl_proxy in sites-enabled folder
  • Under sites-available I have a locations folder that contains various .conf files.

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.

1 Answer 1

1

Try:

location /mystatic {
    index index.html;
    alias /home/anthony/dist;
}
Sign up to request clarification or add additional context in comments.

8 Comments

adding index index.html gives a 404. However, removing that line and just keeping `alias /home/anthony/dist; fetches a 403 error.
Here is the access.log with 403 error and permissions on the dist folder and my conf file gist.github.com/Omnipresent/2c0d17593ca6f868e03f0d4b385d1326
Looks like a permissions issue. Chown to www-data:www-data on the folder and the files in it.
will that work? because my nginx.conf has user nginx in it
chown: invalid user: www-data:www-data I have done chown -R nginx:nginx /home/anthony/dist but that also gives 403 error...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.