【问题标题】:Unable to access app angular + nginx + istio无法访问应用 Angular + nginx + istio
【发布时间】:2020-04-24 15:01:54
【问题描述】:

我正在尝试为一个由 .net 核心服务组成的项目配置 istio 服务网格,其中 angular 6 作为前端。

有趣的是,如果我使用构建部署应用程序并在 docker 内运行,应用程序运行良好。

示例:在节点图像中使用 prod 或 qa 配置的角度服务。

但是如果我通过复制 html 文件夹中的 dist 文件夹内容来使用 nginx 图像,应用程序将无法工作。

注意:Istio 配置已到位。

我创建了目标规则,使用 nginx 部署的角度虚拟服务

  1. 节点端口:

    上游连接错误或在标头之前断开/重置。重置原因:连接失败

  2. ClusterIp:

    请求未到达服务

  3. 负载均衡器

    请求未到达

尝试覆盖 Envoy not connecting 中提到的 nginx 的 default.conf,但文件没有被覆盖。

【问题讨论】:

  • 能否提供目的地规则、虚拟服务、nginx yamls?
  • 嗨@jt97,我发现了这个问题,这是由于nginx上游和nginx.conf/default.conf中的端口配置造成的。我附加的conf需要用于conf。

标签: angular nginx kubernetes istio


【解决方案1】:

经过大量研究,我找到了解决方案。

正如 istio 文档 nginx upstream error 中所述,我在 nginx.conf 中进行了如下更改。

upstream application {
  server 0.0.0.0:[PortNumber];
}

server {
  listen [PortNumber] default_server;

  charset utf-8;

  sendfile on;

  root /usr/share/nginx/html;

  #Caches static assets
  location ~ ^/(assets|bower_components|scripts|styles|views) {
    expires     31d;
    add_header  Cache-Control public;
  }

  #Caches Bundles created by angular cli
  location ~* \.(?:bundle.js|bundle.css)$ {
    expires 1M;
    access_log off;
    add_header Cache-Control "public";
  }

  ##
  # Main file index.html sending not found locations to the main
  ##
  location / {
    proxy_pass http://application;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    expires -1;
    add_header Pragma "no-cache";
    add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";

    try_files $uri $uri/ /index.html = 404;
  }
}

【讨论】:

    猜你喜欢
    • 2020-04-09
    • 1970-01-01
    • 2021-02-23
    • 2015-05-22
    • 2019-04-25
    • 2021-03-15
    • 1970-01-01
    • 1970-01-01
    • 2020-12-06
    相关资源
    最近更新 更多