1

Nginx 和 consul 模板的新手,但我认为除了日志中出现大量噪音(每 15-30 秒有 100 条左右的错误消息)外,我一切正常。似乎是领事模板错误,它无法连接/获取数据......但它确实获取数据并正确构建模板。所以,不确定是什么问题。

如何修复错误?或者,如果它们是意料之中的,我怎么能不将它们记录到标准输出/标准错误,这使我的 nginx 日志记录变得混乱。

谢谢,丹

错误(各种应用程序一遍又一遍地获取这些消息):

2017/01/17 20:07:35 [ERR] (view) "storeKeyPrefix(services/prod/SOMEAPP/SOMEKEY)" store key prefix: error fetching: Get http://consul.example.com:8500/v1/kv/services/prod/SOMEAPP/SOMEKEY/?index=13120537&recurse=&stale=&wait=60000ms: EOF
2017/01/17 20:07:35 [ERR] (runner) watcher reported error: store key prefix: error fetching: Get http://consul.example.com:8500/v1/kv/services/prod/SOMEAPP/SOMEKEY/?index=13120537&recurse=&stale=&wait=60000ms: EOF

Nginx dockerfile

FROM nginx:1.11.8

RUN rm /etc/nginx/conf.d/default.conf
COPY html /usr/share/nginx/html
COPY conf /etc/nginx

RUN DEBIAN_FRONTEND=noninteractive \
    apt-get update -qq && \
    apt-get -y install curl runit unzip && \
    rm -rf /var/lib/apt/lists/*

ENV CT_URL https://releases.hashicorp.com/consul-template/0.15.0/consul-template_0.15.0_linux_amd64.zip
RUN curl -o consul-template.zip $CT_URL && \
 unzip consul-template.zip && \
 chmod a+x consul-template && \
 mv consul-template /usr/bin/consul-template

ADD services/nginx.service /etc/service/nginx/run
RUN chmod a+x /etc/service/nginx/run
ADD services/consul-template.service /etc/service/consul-template/run
RUN chmod a+x /etc/service/consul-template/run

ADD templates/nginx-http-upstream.conf /etc/consul-templates/nginx-http.conf
ADD templates/nginx-tcp-upstream.conf /etc/consul-templates/nginx-tcp.conf

RUN touch /etc/nginx/conf.d/http.conf
RUN touch /etc/nginx/conf.d/tcp.conf

EXPOSE 80
EXPOSE 443

CMD ["/usr/bin/runsvdir", "/etc/service"]

服务/nginx.service

#!/bin/sh

/usr/sbin/nginx -c /etc/nginx/nginx.conf -t && \
exec /usr/sbin/nginx -c /etc/nginx/nginx.conf -g "daemon off;"

服务/consul-template.service

#!/bin/sh

exec consul-template \
    -consul=$CONSUL_HOST:$CONSUL_PORT \
    -log-level=warn \
    -template "/etc/consul-templates/nginx-http.conf:/etc/nginx/conf.d/http.conf:sv hup nginx"\
    -template "/etc/consul-templates/nginx-tcp.conf:/etc/nginx/conf.d/tcp.conf:sv hup nginx"
4

0 回答 0