【问题标题】:Remove an entry from nginx error_log从 nginx error_log 中删除一个条目
【发布时间】:2020-02-04 03:44:09
【问题描述】:

我在我的应用程序中使用 nginx 作为反向代理。我有一个 geth attach 的用例。 用户可以通过 geth attach https://dns-name:port/api-key 来获取 geth 控制台。 示例:

getth 附加https://google-service.net:6000/Yik987hjk

如果出现错误,nginx error_log 会显示此 apikey。 示例:

11:32:14 [错误] 48#0: *12479669 connect() 失败(111:连接 拒绝)同时连接到上游,客户端:1*4.***.****.*01, 服务器:_,请求:“POST /api-key HTTP/1.1”,
上游:“http://127.0.0.1:******”,主机:“*******.******.****.com:port”

我阅读了 nginx 文档,没有办法为 error_log 使用日志格式。 有没有办法配置这个error_log。我不想在日志中显示这个 api-key。

【问题讨论】:

    标签: nginx reverse-proxy


    【解决方案1】:

    更简单的配置示例: 只需在您的 nginx 配置文件中添加一行 error_log off 但请记住,您的 error_log 文件并未创建

    http {
      access_log  /var/log/nginx/access.log  main;
    
      server {
        listen 80;
        location /app1 {
          error_log off; # <----- this WILL work
          proxy_pass http://example.com;
        }
        (...)
      }
    
    }
    

    【讨论】:

      猜你喜欢
      • 2016-12-29
      • 2019-01-18
      • 2012-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-29
      相关资源
      最近更新 更多