首页 > 系统相关 >如何修改ingress-nginx-controller中access.log和error.log的路径?

如何修改ingress-nginx-controller中access.log和error.log的路径?

时间:2022-10-20 15:00:22浏览次数:98  
标签:ingress log int access nginx bool string


ingress-nginx-controller中的配置是通过什么方式来设置的呢?

 

没有! configmap.

 

那要修改access.log和error.log日志的路径,该如何设置?下面一起看下。

 

1、首先,查看当前ingress-nginx-controller中的日志配置

 

bash-5.1$ cat nginx.conf | grep access_log

access_log /var/log/nginx/access.log upstreaminfo if=$loggable;

access_log off;

access_log off;

access_log off;

access_log off;

access_log off;

access_log /var/log/nginx/access.log log_stream ;

access_log off;

bash-5.1$ cat nginx.conf | grep error_log

error_log /var/log/nginx/error.log notice;

error_log /var/log/nginx/error.log notice;

bash-5.1$

 

2、修改configmap

 

kubectl edit configmap -n ingress-nginx ingress-nginx-controller

 

增加如下的配置:

 

  access-log-path: /var/log/nginx/nginx_access.log
  error-log-path: /var/log/nginx/nginx_error.log

 

 

保存配置!

 

3、重启ingress-nginx-controller pod.

 

kubectl delete pod -n ingress-nginx ingress-nginx-controller-z6bh

 

重启成功

[root@nccztsjb-node-23 ~]# kubectl get pod -n ingress-nginx
NAME                             READY   STATUS    RESTARTS   AGE
ingress-nginx-controller-9zlgs   1/1     Running   0          21s
[root@nccztsjb-node-23 ~]# 

 

4、验证配置

 

[root@nccztsjb-node-23 ~]# kubectl exec -it -n ingress-nginx ingress-nginx-controller-9zlgs -- bash

bash-5.1$ cat nginx.conf | grep access_log

access_log /var/log/nginx/nginx_access.log upstreaminfo if=$loggable;

access_log off;

access_log off;

access_log off;

access_log off;

access_log off;

access_log /var/log/nginx/nginx_access.log log_stream ;

access_log off;

bash-5.1$ cat nginx.conf | grep error_log

error_log /var/log/nginx/nginx_error.log notice;

error_log /var/log/nginx/nginx_error.log notice;

bash-5.1$

 

名字修改成功!

 

5、注意!

 

修改之前,必须保证在镜像中存在对应的目录。否则,爆粗如下:

 

6、所有ingress-nginx-controller需要的configmap条目

 

参考如下的链接:

 

https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/

 

name

type

default

add-headers

string

""

allow-backend-server-header

bool

"false"

allow-snippet-annotations

bool

true

annotation-value-word-blocklist

string array

""

hide-headers

string array

empty

access-log-params

string

""

access-log-path

string

"/var/log/nginx/access.log"

http-access-log-path

string

""

stream-access-log-path

string

""

enable-access-log-for-default-backend

bool

"false"

error-log-path

string

"/var/log/nginx/error.log"

enable-modsecurity

bool

"false"

modsecurity-snippet

string

""

enable-owasp-modsecurity-crs

bool

"false"

client-header-buffer-size

string

"1k"

client-header-timeout

int

60

client-body-buffer-size

string

"8k"

client-body-timeout

int

60

disable-access-log

bool

false

disable-ipv6

bool

false

disable-ipv6-dns

bool

false

enable-underscores-in-headers

bool

false

enable-ocsp

bool

false

ignore-invalid-headers

bool

true

retry-non-idempotent

bool

"false"

error-log-level

string

"notice"

http2-max-field-size

string

"4k"

http2-max-header-size

string

"16k"

http2-max-requests

int

1000

http2-max-concurrent-streams

int

128

hsts

bool

"true"

hsts-include-subdomains

bool

"true"

hsts-max-age

string

"15724800"

hsts-preload

bool

"false"

keep-alive

int

75

keep-alive-requests

int

100

large-client-header-buffers

string

"4 8k"

log-format-escape-none

bool

"false"

log-format-escape-json

bool

"false"

log-format-upstream

string

$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $request_length $request_time [$proxy_upstream_name] [$proxy_alternative_upstream_name] $upstream_addr $upstream_response_length $upstream_response_time $upstream_status $req_id

log-format-stream

string

[$remote_addr] [$time_local] $protocol $status $bytes_sent $bytes_received $session_time

enable-multi-accept

bool

"true"

max-worker-connections

int

16384

max-worker-open-files

int

0

map-hash-bucket-size

int

64

nginx-status-ipv4-whitelist

[]string

"127.0.0.1"

nginx-status-ipv6-whitelist

[]string

"::1"

proxy-real-ip-cidr

[]string

"0.0.0.0/0"

proxy-set-headers

string

""

server-name-hash-max-size

int

1024

server-name-hash-bucket-size

int

<size of the processor’s cache line>

proxy-headers-hash-max-size

int

512

proxy-headers-hash-bucket-size

int

64

plugins

[]string

 

reuse-port

bool

"true"

server-tokens

bool

"false"

ssl-ciphers

string

"ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384"

ssl-ecdh-curve

string

"auto"

ssl-dh-param

string

""

ssl-protocols

string

"TLSv1.2 TLSv1.3"

ssl-session-cache

bool

"true"

ssl-session-cache-size

string

"10m"

ssl-session-tickets

bool

"false"

ssl-session-ticket-key

string

<Randomly Generated>

ssl-session-timeout

string

"10m"

ssl-buffer-size

string

"4k"

use-proxy-protocol

bool

"false"

proxy-protocol-header-timeout

string

"5s"

use-gzip

bool

"false"

use-geoip

bool

"true"

use-geoip2

bool

"false"

enable-brotli

bool

"false"

brotli-level

int

4

brotli-min-length

int

20

brotli-types

string

"application/xml+rss application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/javascript text/plain text/x-component"

use-http2

bool

"true"

gzip-level

int

1

gzip-types

string

"application/atom+xml application/javascript application/x-javascript application/json application/rss+xml application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css text/javascript text/plain text/x-component"

worker-processes

string

<Number of CPUs>

worker-cpu-affinity

string

""

worker-shutdown-timeout

string

"240s"

load-balance

string

"round_robin"

variables-hash-bucket-size

int

128

variables-hash-max-size

int

2048

upstream-keepalive-connections

int

320

upstream-keepalive-time

string

"1h"

upstream-keepalive-timeout

int

60

upstream-keepalive-requests

int

10000

limit-conn-zone-variable

string

"$binary_remote_addr"

proxy-stream-timeout

string

"600s"

proxy-stream-next-upstream

bool

"true"

proxy-stream-next-upstream-timeout

string

"600s"

proxy-stream-next-upstream-tries

int

3

proxy-stream-responses

int

1

bind-address

[]string

""

use-forwarded-headers

bool

"false"

enable-real-ip

bool

"false"

forwarded-for-header

string

"X-Forwarded-For"

compute-full-forwarded-for

bool

"false"

proxy-add-original-uri-header

bool

"false"

generate-request-id

bool

"true"

enable-opentracing

bool

"false"

opentracing-operation-name

string

""

opentracing-location-operation-name

string

""

zipkin-collector-host

string

""

zipkin-collector-port

int

9411

zipkin-service-name

string

"nginx"

zipkin-sample-rate

float

1.0

jaeger-collector-host

string

""

jaeger-collector-port

int

6831

jaeger-endpoint

string

""

jaeger-service-name

string

"nginx"

jaeger-propagation-format

string

"jaeger"

jaeger-sampler-type

string

"const"

jaeger-sampler-param

string

"1"

jaeger-sampler-host

string

"http://127.0.0.1"

jaeger-sampler-port

int

5778

jaeger-trace-context-header-name

string

uber-trace-id

jaeger-debug-header

string

uber-debug-id

jaeger-baggage-header

string

jaeger-baggage

jaeger-trace-baggage-header-prefix

string

uberctx-

datadog-collector-host

string

""

datadog-collector-port

int

8126

datadog-service-name

string

"nginx"

datadog-environment

string

"prod"

datadog-operation-name-override

string

"nginx.handle"

datadog-priority-sampling

bool

"true"

datadog-sample-rate

float

1.0

main-snippet

string

""

http-snippet

string

""

server-snippet

string

""

stream-snippet

string

""

location-snippet

string

""

custom-http-errors

[]int

[]int{}

proxy-body-size

string

"1m"

proxy-connect-timeout

int

5

proxy-read-timeout

int

60

proxy-send-timeout

int

60

proxy-buffers-number

int

4

proxy-buffer-size

string

"4k"

proxy-cookie-path

string

"off"

proxy-cookie-domain

string

"off"

proxy-next-upstream

string

"error timeout"

proxy-next-upstream-timeout

int

0

proxy-next-upstream-tries

int

3

proxy-redirect-from

string

"off"

proxy-request-buffering

string

"on"

ssl-redirect

bool

"true"

force-ssl-redirect

bool

"false"

whitelist-source-range

[]string

[]string{}

skip-access-log-urls

[]string

[]string{}

limit-rate

int

0

limit-rate-after

int

0

lua-shared-dicts

string

""

http-redirect-code

int

308

proxy-buffering

string

"off"

limit-req-status-code

int

503

limit-conn-status-code

int

503

enable-syslog

bool

false

syslog-host

string

""

syslog-port

int

514

no-tls-redirect-locations

string

"/.well-known/acme-challenge"

global-auth-url

string

""

global-auth-method

string

""

global-auth-signin

string

""

global-auth-signin-redirect-param

string

"rd"

global-auth-response-headers

string

""

global-auth-request-redirect

string

""

global-auth-snippet

string

""

global-auth-cache-key

string

""

global-auth-cache-duration

string

"200 202 401 5m"

no-auth-locations

string

"/.well-known/acme-challenge"

block-cidrs

[]string

""

block-user-agents

[]string

""

block-referers

[]string

""

proxy-ssl-location-only

bool

"false"

default-type

string

"text/html"

global-rate-limit-memcached-host

string

""

global-rate-limit-memcached-port

int

11211

global-rate-limit-memcached-connect-timeout

int

50

global-rate-limit-memcached-max-idle-timeout

int

10000

global-rate-limit-memcached-pool-size

int

50

global-rate-limit-status-code

int

429

service-upstream

bool

"false"

ssl-reject-handshake

bool

"false"

debug-connections

[]string

"127.0.0.1,1.1.1.1/24"

标签:ingress,log,int,access,nginx,bool,string
From: https://www.cnblogs.com/chuanzhang053/p/16809896.html

相关文章

  • CentOS8 通过 loganalyzer 展示数据库中的日志
    loganalyzer:loganalyzer是用php语言实现的日志管理系统,可将MySQL数据库的日志用丰富的WEB方式进行展示官网:https://loganalyzer.adiscon.com环境准备:日志客户端:10.......
  • nginx配置访问WGCLOUD页面URL地址不加后缀/wgcloud
    nginx配置如下这样就可以通过域名或IP直接访问WGCLOUD页面了,不用再加后面的/wgcloud了注意把localhost改为自己的实际server主机IPserver{listen......
  • weblogic洞若观火第4篇之手工创建域
    引言上一篇文章,主要讲解了weblogic的源码安装,涉及到了:服务器规划、软件版本、硬件配置、源码安装weblogic。在本篇文章中,我们接着介绍:weblogic的手工创建域。域Domain域是......
  • nginx系列之一:nginx入门
    nginx系列之一:nginx入门@目录nginx系列之一:nginx入门前言一、pandas是什么?二、使用步骤1.引入库2.读入数据总结前言nginx系列之一:nginx入门nginx系列之二:配置文件解读......
  • Linux 启用rsyslog的启用网络日志服务
    网络日志服务功能:  将多个远程主机的日志集中发送到一台日志服务器上存储,方便后期的管理。说明:  rsyslog服务和apache、php一样基于模块化设计,需要启用对应的功能就......
  • Nginx 在windows下的安装及使用(负载均衡 多服务器配置)
    1.下载nginxhttp://nginx.org/en/download.html下载稳定版本,以nginx/Windows-1.12.2为例,直接下载nginx-1.12.2.zip下载后解压,解压后如下  2.启动nginx有很多种方......
  • Nginx 解决跨域请求
    一遇到到下这种问题,大家是不是很头疼,没错,这就是跨域问题,首先我们先说一下什么是跨域?为什么会跨域?什么问题造成的?  跨域简单来说,就是浏览器url地址和访问数据接口的地......
  • Nginx 在Windows下配置证书
    1、从证书出售商获取证书文件,并复制到nginx的conf目录下2、打开nginx.conf配置文件,写入以下代码server{listen443ssl;......
  • nginx做负载均衡服务器,配置动静分离
    nginx做负载均衡服务器,配置动静分离目录nginx做负载均衡服务器,配置动静分离部署LNMP源码安装nginx二进制安装mysql源码安装php配置nginx部署LAMP源码安装httpd二进制安装......
  • nginx负载均衡读写分离
    目录nginx负载均衡读写分离nginx主机:源码部署nginxlnmp主机http主机测试动静分离nginx负载均衡读写分离环境说明主机名IP地址服务系统nginx192.168.34.13......