如何从入口文件中的指定路径重定向到服务的根路径 [英] How to redirect from specified path in the ingress file to the root path of the service

查看:94
本文介绍了如何从入口文件中的指定路径重定向到服务的根路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的入口定义如下;

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: webserver-ingress
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/configuration-snippet: |
     rewrite ^(/master)$ $1/ redirect;
spec:
  rules:
  - host: my.test.domain
    http:
      paths:
      - path: /master
        backend:
          serviceName: airflow-webserver-svc
          servicePort: 80

服务airflow-webserver-svc指向气流Web服务器.入口现在在GET/上命中了气流Web服务器,但是该站点从my.test.domain/master重定向到my.test.domain/home,这是气流Web服务器的登录页面,但是nginx返回了该链接上未找到的404页面:(.如果我更改入口path: /,一切正常,请转到my.test.domain打开airflow webserver/home页面,然后将其重定向到/login页面.但是我需要从我的页面中打开同一页面. test.domain/master.我该怎么做?

The service airflow-webserver-svc is pointing towards airflow webserver. the ingress now hits airflow webserver on GET /, but the site gets redirected from my.test.domain/master to my.test.domain/home which is the landing page of airflow webserver, but nginx returns 404 Page not found on that link :(. All works fine if I change the ingress path: /, going to my.test.domain open up airflow webserver /home page, which then gets redirected to /login page. But I need to open the same webpage from my.test.domain/master. How can I do that ?

它不会从路径重定向:"/master";到"/"服务内部.是 有什么方法可以从入口文件中的指定路径重定向到服务的根路径?

It doesn't redirect from path: "/master" to "/" inside the service. Is there any way to redirect from specified path in the ingress file to the root path of the service?

更新:

发现在代理后面运行时,气流有其特殊的配置要做(解决方案,但还是没有运气.

Found out that airflow has its special configuration to do, when running behind proxy (here). I applied this solution but still no luck.

推荐答案

通过使入口保持与上述相同的方式使其工作,并将其添加到webserver部分的airflow配置中来使其工作;

Made it work by keeping ingress same as mentioned above, and adding this in airflow config under webserver section;

[webserver]
  enable_proxy_fix = True
  base_url = http://my.test.domain/master/

然后重新启动Web服务器.

and restart the webserver.

这篇关于如何从入口文件中的指定路径重定向到服务的根路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆