在nginx-ingress-controller
的configmap中添加多个主机:
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-ingress-controller
namespace: ingress
data:
use-proxy-protocol: "true"
use-forwarded-headers: "true"
log-format: '{"time": "$time_iso8601", '...
proxy-read-timeout: "600"
proxy-send-timeout: "600"
proxy-body-size: "256m"
proxy-buffering: "off"
proxy-buffer-size: "4k"
service-node-port-range: "20000-32767"
proxy-real-ip-cidr: "10.0.0.0/8"
enable-leader-election: "false"
default-ssl-certificate: ingress/tls-secret
client-max-body-size: "128m"
client-body-buffer-size: "128m"
real-ip-header: "x-real-ip"
secure-backends: "false"
ssl-protocols: "TLSv1.2 TLSv1.3"
ssl-ciphers: "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"
worker-processes: "2"
use-http2: "true"
server-tokens: "false"
config:
use-forwarded-headers: "true"
server-snippets: |
location / {
if ($http_host = "host1.example.com") {
proxy_pass http://backend1;
}
if ($http_host = "host2.example.com") {
proxy_pass http://backend2;
}
}
以上configmap添加了两个主机host1.example.com
和`