本文介绍了如何使traefik与graylog2一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入Web界面网址时出现此错误:

I'm getting this error when entering to web interface url:

 Server currently unavailable
We are experiencing problems connecting to the Graylog server running on http://127.0.0.1:9000/api. Please verify that the server is healthy and working correctly.

You will be automatically redirected to the previous page once we can connect to the server.

Do you need a hand? We can help you.

More details

docker-compose.yml:

docker-compose.yml:

graylog:
    image: graylog2/server:2.3.0-1
    environment:
      GRAYLOG_PASSWORD_SECRET: xxx
      GRAYLOG_ROOT_PASSWORD_SHA2: xxx
      GRAYLOG_WEB_ENDPOINT_URI: http://example.com/api/
      GRAYLOG_REST_LISTEN_URI:  http://0.0.0.0:9000/api/
      GRAYLOG_WEB_LISTEN_URI: http://0.0.0.0:9000/
      GRAYLOG_ELASTICSEARCH_CLUSTER_NAME: graylog
      GRAYLOG_ELASTICSEARCH_HOSTS: http://graylog-elasticsearch:9200
    depends_on:
      - graylog-elasticsearch
      - mongo
    networks:
      - traefik
      - default
      - graylog
    deploy:
      labels:
        - "traefik.port=9000"
        - "traefik.tags=logging"
        - "traefik.docker.network=infra_traefik"
        - "traefik.backend=graylog"
      restart_policy:
        condition: on-failure
      replicas: 1
      placement:
        constraints:
          - node.labels.name == manager-1

如您所见,一切都会正常进行.

As you see everything should work without any problem.

这是netstat显示的内容:

Here's what netstat shows:

root@6399d2a13c5d:/usr/share/graylog# netstat -tulnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:9000            0.0.0.0:*               LISTEN      -
tcp        0      0 127.0.0.11:42255        0.0.0.0:*               LISTEN      -
udp        0      0 127.0.0.11:51199        0.0.0.0:*                           -

这是容器printenv:

Here's container printenv:

    root@6399d2a13c5d:/usr/share/graylog# printenv
    GRAYLOG_ELASTICSEARCH_CLUSTER_NAME=graylog
    HOSTNAME=6399d2a13c5d
    TERM=xterm
    GRAYLOG_WEB_ENDPOINT_URI=http://example.com/api/
    GRAYLOG_REST_LISTEN_URI=http://0.0.0.0:9000/api/
    GRAYLOG_ROOT_PASSWORD_SHA2=ччч
    CA_CERTIFICATES_JAVA_VERSION=20140324
    GRAYLOG_PASSWORD_SECRET=ччч
    GRAYLOG_REST_TRANSPORT_URI=http://example.com/api/
    PWD=/usr/share/graylog
    JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre
    LANG=C.UTF-8
    JAVA_VERSION=8u72
    SHLVL=1
    HOME=/root
    JAVA_DEBIAN_VERSION=8u72-b15-1~bpo8+1
    GRAYLOG_ELASTICSEARCH_HOSTS=http://graylog-elasticsearch:9200
    GRAYLOG_WEB_LISTEN_URI=http://0.0.0.0:9000/
    GOSU_VERSION=1.7
    GRAYLOG_SERVER_JAVA_OPTS=-Xms1g -Xmx2g -XX:NewRatio=1 -XX:MaxMetaspaceSize=256m -server -XX:+ResizeTLAB -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSClassUnloadingEnabled -XX:+UseParNewGC -XX:-OmitStackTraceInFastThrow
    _=/usr/bin/printenv

我认为问题可能出在该自定义标头中,可能需要Graylog:

I assume problem maybe within this custom header which graylog probably need:

RequestHeader set X-Graylog-Server-URL "http://graylog.example.org/api/"

推荐答案

对于本实施示例,我假设example.org是远程主机,而不是127.0.0.1.在这种情况下,假设需要其他标头是正确的.
根据我的经验,您应该删除api/作为最终用户的Web访问权限


您将需要设置请求标头X-Graylog-Server-URL.例如curl -H "X-Graylog-Server-URL: http://graylog.example.org/" http://127.0.0.1:9000.
Graylog Web代理配置如果您想在Graylog服务器之前设置Web服务器,则可以提供一些很好的信息.很遗憾,在撰写本文时, Docker示例不包括基本的nginx配置

For the implementation example you have given I am assuming that example.org is a remote host rather than 127.0.0.1. In that situation, you are correct in assuming that the additional header is needed.
From my experience you should strip api/ for the the end user web access


You will need to set the request header X-Graylog-Server-URL. eg curl -H "X-Graylog-Server-URL: http://graylog.example.org/" http://127.0.0.1:9000.
Graylog web proxy config gives some good info if you want to setup a webserver in front of your graylog server. It's just a pity that (at the time of writing this) the Docker Examples do not include a basic nginx config

我正在使用kubernetes,必须将以下内容添加到我的入口注释中才能正确吸引流量

I am using kubernetes and had to add the following to my ingress annotation to get traffic in correctly

ingress:
  annotations:
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header X-Graylog-Server-URL https://$server_name/;

这篇关于如何使traefik与graylog2一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 05:30