首页 > 解决方案 > 使用 nginx 作为反向代理在 Azure Service Fabric 中部署 Angular8 应用程序

问题描述

我有一个部署在 Azure 服务结构中并且工作正常的 Angular 应用程序。我在 nginx 中提供了路径,它能够重定向到正确的路径。现在我计划根据语言创建单独的文件夹。所以以前,我的 wwwroot 文件夹中只有一个 index.html 文件和 5 个包。但是现在在我的 wwwroot 文件夹中,我有每种语言的文件夹,并且在各自的文件夹中都有这六个文件。

上一个 nginx 路径

    location ~* /StudentAdministration {
http://127.0.0.1:19081/StudentAdministration/StudentAdministrationClient; 

在我的改变之后

        map $http_accept_language $lang {
       default en;
        ~en en;
        ~es es;
        ~fr fr;
    }

    location ~* /StudentAdministration(.*) {
http://127.0.0.1:19081/StudentAdministration/StudentAdministrationClient/$lang$1; 
    }   

我能够使用 map 函数正确获取 lang 值。

当我尝试点击 url/StudentAdministration 时,它会抛出错误。

开发模式 切换到开发环境会显示有关所发生错误的详细信息。

我的计划是点击 url/StudentAdministration 以便它进入 wwwroot 中的 en 文件夹并获取 index.html,然后在其中加载捆绑包。但它不起作用。

标签: angularnginxangular-cliazure-service-fabric

解决方案


推荐阅读