繁体   English   中英

Ingress nginx路径路由

[英]Ingress nginx path routing

我在 AKS 上部署了一个 React 应用程序,应用程序登录页面的 URL 是https://myapp.host.com/dev/

目前该应用程序有多个屏幕可以导航,例如:/profile

当我单击配置文件导航按钮时,它会重定向到这个 url: https://myapp.host.com/profile这不是我想要的。 虽然配置文件页面能够加载,但是如果刷新页面,它将返回错误,因为应用程序无法读取https://myapp.host.com/profile URL。我希望它是https ://myapp.host.com/dev/profile这样即使页面刷新,应用程序也能够加载。

这是我的入口配置:

ingress:
  name: myapp-ingress
  annotations: 
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/rewrite-target: /$1
  hosts: 
  - host: myapp.host.com
    paths: 
    - path: /dev/(.*)
      pathType: Prefix
      backend: 
        service:
          name: myapp-svc
          port: 
            number: 8080
  tls: 
  - hosts: 
    - myapp.host.com
    secretName: myapp-ingress-tls-secret

我应该在配置中更改什么?

我也是 ingress 的新手,但也许是因为那个

根据 ingress-nginx 文档, nginx.ingress.kube.netes.io/rewrite-target -target 表示必须重定向流量的目标 URI。

所以nginx.ingress.kube.netes.io/rewrite-target: /$1意味着当你匹配/dev/profile它将重定向到/profile所以也许你可以删除它并重试?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM