您应该使用ConfigMap到customize the NGINX configuration:
07001 allow you to decouple configuration artifacts from image
content to keep containerized applications portable.
The ConfigMap API resource stores configuration data as key-value
pairs. The data provides the configurations for system components for
the nginx-controller.
例如.:
创建以下配置映射:
apiVersion: v1
data:
log-format-upstream: '$remote_addr - $request_id - [$proxy_add_x_forwarded_for] - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status'
kind: ConfigMap
metadata:
name: nginx-ingress-config
并确保您将–configmap = $(POD_NAMESPACE)/ nginx-ingress-config用作nginx-ingress-controller(example from offical repo here)的命令参数.