我正在尝试在我的 K8s 应用程序中创建一个后备路由。我有一个 Pod 服务于一个后备应用程序,该应用程序在 URL http://domain:80/error 上返回一个 404 页面。如果我调用 http://application/error 它工作正常,但一旦我调用 http://application/test 或 http://application/dummy 或 http://application/error-page123 就会失败,它返回 Kong 404页。
我想将所有不存在的路由路由到 /error,我该如何实现。
我的 404 配置 -
- name: con-404
url: http://con-404:80/error-page
routes:
- name: con-404
paths:
- /error-page.*
hosts:
- '{{ .Values.domainName }}'
preserve_host: true
strip_path: true
日志:
72.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /_next/static/chunks/19e98d60.b3e7ae89433b365ce824.js HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /_next/static/chunks/pages/_app-0e21341ffcede83f5f91.js HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /_next/static/37136da7f9f13c7143c0ab3fbca0b705e051674e/_buildManifest.js HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /_next/static/chunks/47b02e17009e033f7403a15a7895e4e8f1a7e0a0.b42e815d27210619a63a.js HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /_next/static/37136da7f9f13c7143c0ab3fbca0b705e051674e/_ssgManifest.js HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /_next/static/chunks/pages/error-page-89e06fc8f15977bfc559.js HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /fonts/Roboto-Regular.woff2 HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /fonts/Roboto-Regular.woff HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /fonts/Roboto-Regular.ttf HTTP/1.1" 404 48 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"
2021/12/15 16:33:12 [debug] 1098#0: *3062 [lua] init.lua:973: balancer(): setting address (try 1): 10.100.7.138:80
2021/12/15 16:33:12 [debug] 1098#0: *3062 [lua] init.lua:1002: balancer(): enabled connection keepalive (pool=10.100.7.138|80, pool_size=60, idle_timeout=60, max_requests=100)
172.16.3.236 - - [15/Dec/2021:16:33:12 +0000] "GET /error-page/favicons/favicon-32x32.png HTTP/1.1" 200 2090 "https://atul.aws-domain.com/error-page123" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36"e