Nginx位置无法按预期工作

问题描述 投票:0回答:1

我的VPS中有两个角度项目,主项目位于/ home / first_app /,第二个位于/ home / second_app /

这是我的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
}

第一个应用程序运行良好,但我无法使用:mydomain.com/second_app访问第二个应用程序。它始终采用/ location块。

在调试日志中,我发现:

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

谢谢 !

angular redirect nginx location vps
1个回答
-1
投票

首先,plz创建一个dist构建。

使用Angular CLI。

$ng build --prod

之后尝试在dist /文件夹上使用本地服务器。你不能安装nws。

npm install -g nws

并运行

nws

并转到此网址。 http://localhost:3030

如果你看到你的应用运行正常,你可以丢弃它。之后,也许你可以关注这个solution

好吧,我希望这可以派上用场。

© www.soinside.com 2019 - 2024. All rights reserved.