Ingress-nginx: Custom 404 redirects

Created on 29 Nov 2018  路  2Comments  路  Source: kubernetes/ingress-nginx

NGINX Ingress controller version: 0.21.0

Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-24T06:54:59Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.6-gke.11", GitCommit:"42df8ec7aef509caba40b6178616dcffca9d7355", GitTreeState:"clean", BuildDate:"2018-11-08T20:06:00Z", GoVersion:"go1.9.3b4", Compiler:"gc", Platform:"linux/amd64"}

Environment:

  • Cloud provider or hardware configuration: gke
  • OS (e.g. from /etc/os-release): cOS
  • Kernel (e.g. uname -a): Linux nginx-ingress-685bf7d798-mn77t 4.14.65+ #1 SMP Sun Sep 9 02:18:33 PDT 2018 x86_64 GNU/Linux

  • Install tools: Helm

  • Others:

What happened:
when error_page 404 "https://domain.com/error"; is specified in server-snippet in the configmap the custom 404 redirect doesn't happen.
However the 50x redirects work just fine.
snippet follows:

  server-snippet: |
    error_page 404 "https://domain/error";
    error_page 500 502 503 504 "https://otherdomain.com/maintain/";

503 works fine, 404 doesn't

What you expected to happen:
404 redirect to work

How to reproduce it (as minimally and precisely as possible):
Create a simple ingress with the above server-snippet in the configmap and attempt to reach a page that doesn't exist.

Anything else we need to know:

Most helpful comment

@aledbf much obliged. That did the trick.

All 2 comments

@dcherniv you also need proxy_intercept_errors聽on in the snippet

@aledbf much obliged. That did the trick.

Was this page helpful?
0 / 5 - 0 ratings