From b5173fc143d167d9d6702bb01f5993c957ad6892 Mon Sep 17 00:00:00 2001 From: rohow Date: Wed, 21 Aug 2024 10:19:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(nginx):=20=E5=A2=9E=E5=8A=A0=E9=BB=98?= =?UTF-8?q?=E8=AE=A4404=20503=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/infra/net/nginx/configmap-html.yaml | 244 +++++++++++++++++++++++ apps/infra/net/nginx/helmchart.yaml | 18 ++ 2 files changed, 262 insertions(+) create mode 100644 apps/infra/net/nginx/configmap-html.yaml diff --git a/apps/infra/net/nginx/configmap-html.yaml b/apps/infra/net/nginx/configmap-html.yaml new file mode 100644 index 0000000..2cf4e90 --- /dev/null +++ b/apps/infra/net/nginx/configmap-html.yaml @@ -0,0 +1,244 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: custom-html + namespace: infra-net +data: + 404.html: | + + + + + 404 页面未找到 + + + +
+
+
+
+
+
+
+
+
+

404

+
+

页面未找到

+

您正在寻找的页面可能已被删除、名称已更改或暂时不可用。

+ 首页 +
+
+ + diff --git a/apps/infra/net/nginx/helmchart.yaml b/apps/infra/net/nginx/helmchart.yaml index 3299ed2..98b9624 100644 --- a/apps/infra/net/nginx/helmchart.yaml +++ b/apps/infra/net/nginx/helmchart.yaml @@ -30,6 +30,8 @@ spec: config: use-forwarded-headers: "true" allow-snippet-annotations: "true" + # 自定义错误页面 + custom-http-errors: "404,503" # 缓存配置 http-snippet: | proxy_cache_path /tmp/nginx-cache levels=1:2 keys_zone=cache:2m max_size=100m inactive=7d use_temp_path=off; @@ -114,3 +116,19 @@ spec: - name: crowdsec-bouncer-plugin mountPath: /etc/nginx/lua/plugins/crowdsec subPath: crowdsec + defaultBackend: + enabled: true + image: + registry: registry.k8s.io + image: ingress-nginx/custom-error-pages + tag: v1.0.1 + extraVolumes: + - name: custom-html + configMap: + name: custom-html + extraVolumeMounts: + - name: custom-html + mountPath: /www + # 和controller部署同一节点 + nodeSelector: + svccontroller.k3s.cattle.io/enablelb: "true"