部署在Kubernetes入口路径上时无法获取angular 7进行路由

时间:2019-02-28 21:00:42

标签: angular nginx kubernetes kubernetes-ingress

在通过Kubernetes Ingress路径部署Angular之后,我无法将其路由。它以开发人员模式运行,当导航到host.com/op上的服务节点端口ip地址(xxx.xxx.xxx.xxx:pppp)时,即可使用。例如host.com/op/page-无法路由到页面。

入口:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress
  annotations:
    kubernetes.io/ingress.global-static-ip-name: [redacted]
spec:
  rules:
  - host: host.com
    http:
      paths:
      - path: /
        backend:
          serviceName:service-a
          servicePort: 80
      - path: /api/*
        backend:
          serviceName: service-b
          servicePort: 80
      - path: /op/*
        backend:
          serviceName: angular7-nginx-service
          servicePort: 80
  backend:
    serviceName: service-a
    servicePort: 80

我的Nginx服务器配置文件

server {
  listen 80;
  charset utf-8;
  sendfile on;
  root /usr/share/nginx/html;

  location / {
    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;
  }

}

0 个答案:

没有答案