0

I have two angular projects in my VPS, the main project is found at /home/first_app/, the second one is at /home/second_app/

This is my nginx conf:

server_name www.my_domain.com my_domain.com

location /second_app {
    alias /home/second_app/dist;
    try_files $uri $uri/ /index.html =404;
}

location / {
    root /home/first_app/dist;
    # First attempt to serve request as file, then
    # as directory, then fall back to displaying a 404.
    try_files $uri $uri/ /index.html =404;
    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
}

The first app works well but I cannot access to the second app by using: mydomain.com/second_app. It always took the / location block.

In the debug log, I found:

test location "/"
test location "second_app"
use configuration "/"

Thanks !

Trong Lam Phan
  • 2,292
  • 3
  • 24
  • 51
  • Can you try to move first location section (location /second_app) to second position? – YD1m Dec 26 '17 at 16:04

1 Answers1

-1

First of all plz create a dist build.

Using Angular CLI.

$ng build --prod

after that try using a local server on your dist/ folder. you cant install nws.

npm install -g nws

and run

nws

and go to this url. http://localhost:3030

if you see your apps running fine you can discard its. after that maybe you can follow this solution.

Well, i hope this can be handy.

Carlos Rojas
  • 5,547
  • 2
  • 14
  • 13
  • This by no means resolves the issue in question, the resolution or answer should be related to a proper configuration in nginx not using a build server or proxy. – Jose Villalobos Aug 06 '18 at 03:05