I have a problem with my Nginx configuration. I have two separate angularjs2 projects which should work with one nginx instance. The applications are separated into two folder /admin and /webapp.
Now what I'm trying to do is when I call mydomain.com it should open the app in /webapp. If I call mydomain.com/admin it should open the admin application (which is also an angularj2 app).
What I've tried so far is the following:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html/webapp;
index index.html index.htm;
location / {
index index.html index.htm;
try_files $uri /index.html;
}
location /admin/ {
alias /usr/share/nginx/html/admin/;
try_files /admin/$uri /admin/index.html;
}
}
I hope I can get help. Thanks in advance!
Try:
The
root
directive is preferred over thealias
directive. See this document for details.The
index
directive is inherited and does not need to be repeated.The
$uri/
terms will encouragenginx
to append a/
to the URI of a directory so that theindex
directive works correctly. I also corrected some of yourtry_files
terms. See this document for details.