Ingress-nginx: How to use the annotation "nginx.ingress.kubernetes.io/proxy-redirect-from/to"

Created on 27 Aug 2018  路  2Comments  路  Source: kubernetes/ingress-nginx

Is this a request for help?
Yes.

What keywords did you search in NGINX Ingress controller issues before filing this one?
proxy-redirect-from/to(nginx-ingress) , proxy_pass(nginx)


Is this a BUG REPORT or FEATURE REQUEST? (choose one):
FEATURE REQUEST

If this is a FEATURE REQUEST, please:

  • Describe in detail the feature/behavior/change you'd like to see.
    When I use the annotation "nginx.ingress.kubernetes.io/proxy-redirect-from/to" in ingress-nginx,it's doesn't working.And there was no example for it.So could you tell how to use this annotation.My requirement is the same with "proxy_pass" in nginx.Now I want to use ingress-nginx to instead nginx.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: open-api-service-ingress
namespace: java-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/proxy-redirect-from: "http://www.google.com"
nginx.ingress.kubernetes.io/proxy-redirect-to: "/one"
nginx.ingress.kubernetes.io/enable-access-log: "ture"
nginx.ingress.kubernetes.io/configuration-snippet: |
access_log /var/log/nginx/open-api_access.log upstreaminfo;
error_log /var/log/nginx/open-api_error.log notice;
spec:
rules:

  • http:
    paths:

    • path: /open-api

      backend:

      serviceName: open-api-service

      servicePort: 8080

NGINX Ingress controller version:
0.18.0

Kubernetes version (use kubectl version):
1.9.3

Most helpful comment

@aledbf
Could you please tell me how to use it?When I define a host ,it's still not working.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: open-api-service-ingress
namespace: java-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/proxy-redirect-from: "http://www.google.com"
nginx.ingress.kubernetes.io/proxy-redirect-to: "/one/"
nginx.ingress.kubernetes.io/enable-access-log: "ture"
nginx.ingress.kubernetes.io/configuration-snippet: |
access_log /var/log/nginx/open-api_access.log upstreaminfo;
error_log /var/log/nginx/open-api_error.log notice;
spec:
rules:

  • host: www.adoo123.com
    http:
    paths:

    • path: /

      backend:

      serviceName: open-api-service

      servicePort: 8080

All 2 comments

Closing. The annotation proxy-redirect-from/to works only when you define a host in the ingress rule.

@aledbf
Could you please tell me how to use it?When I define a host ,it's still not working.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: open-api-service-ingress
namespace: java-service
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/proxy-redirect-from: "http://www.google.com"
nginx.ingress.kubernetes.io/proxy-redirect-to: "/one/"
nginx.ingress.kubernetes.io/enable-access-log: "ture"
nginx.ingress.kubernetes.io/configuration-snippet: |
access_log /var/log/nginx/open-api_access.log upstreaminfo;
error_log /var/log/nginx/open-api_error.log notice;
spec:
rules:

  • host: www.adoo123.com
    http:
    paths:

    • path: /

      backend:

      serviceName: open-api-service

      servicePort: 8080

Was this page helpful?
0 / 5 - 0 ratings