简体   繁体   English

ingress-nginx永久重定向301无法正常工作

[英]ingress-nginx permanent redirect 301 not working

UPDATE: This problem solved itself. 更新:这个问题解决了。 I can't tell why. 我不知道为什么。 I just tried again the next day and it worked with the config below. 我第二天再次尝试,它使用下面的配置。

I'm using the "ingress-nginx" ingress controller (v. 0.12.0). 我正在使用“ingress-nginx”入口控制器(v.0.12.0)。 It works fine except for permanent redirects . 永久重定向外,它工作正常。

In order to redirect foo.example.com to https://google.com I applied the following ingress config: 为了将foo.example.com重定向到https://google.com我应用了以下入口配置:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    # nginx.ingress.kubernetes.io/ssl-redirect: "false"
    nginx.ingress.kubernetes.io/permanent-redirect: "https://google.com"
  name: redirect-test
  namespace: default
spec:
  rules:
  - host: foo.example.com
    http:
      paths:
      - backend:
          serviceName: default-backend 
          servicePort: 80
  tls:
  - hosts:
    - foo.example.com
    secretName: domains-tls

But if I enter foo.example.com in the browser I get this: 但如果我在浏览器中输入foo.example.com ,我会得到:

We're sorry, but we were unable to process the redirection request for the site you are attempting to access. 很抱歉,我们无法处理您尝试访问的网站的重定向请求。

If you feel that you are receiving this message in error, please check the URL and try your request again. 如果您认为错误地收到了此邮件,请检查该网址并再次尝试使用您的请求。

UT UT

(RF) (RF)

Does anyone know what goes wrong here? 有谁知道这里出了什么问题?

I had this same issue, 我有同样的问题,

I fixed it by upgrading the nginx-ingress chart from nginx-ingress-0.8.13 to nginx-ingress-0.22.0 我通过将nginx-ingress图表从nginx-ingress-0.8.13nginx-ingress-0.22.0

I assume the permanent redirect annotation nginx.ingress.kubernetes.io/permanent-redirect did not existed in 0.8.13 . 我假设永久重定向注释nginx.ingress.kubernetes.io/permanent-redirect0.8.13不存在。

So either helm upgrade your chart or upgrade your nginx-ingress directly. 因此,掌舵升级您的图表或直接升级您的nginx-ingress。

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

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