Graylog2 / graylog2-server

Free and open log management
https://www.graylog.org
Other
7.31k stars 1.05k forks source link

Adding a path to GRAYLOG_HTTP_EXTERNAL_URI and GRAYLOG_HTTP_PUBLISH_URI breaks web interface in 5.1 #15536

Closed drewmiranda-gl closed 1 year ago

drewmiranda-gl commented 1 year ago

When adding an additional path to http_publish_uri and http_external_uri (OR GRAYLOG_HTTP_EXTERNAL_URI and GRAYLOG_HTTP_PUBLISH_URI for docker), Graylog web interface does not load and shows an error:

Loading component failed: Absolute route path "/" nested under path "/logs/" is not valid. An absolute child route path must start with the combined path of all its parent routes.

There are no errors in server.log

Browser's inspect/console log:

api/plugins/org.graylog.plugins.license/licenses/status/for-subject?subject=/license/enterprise/views:1     Failed to load resource: the server responded with a status of 404 (Not Found)

vendor.8a712d83b311029bb0b6.js:672 Error: Absolute route path "/" nested under path "/logs/" is not valid. An absolute child route path must start with the combined path of all its parent routes.
    at o (router.js:270:11)
    at Et (router.js:634:7)
    at router.js:668:7
    at Array.forEach (<anonymous>)
    at S (router.js:663:10)
    at Et (router.js:647:7)
    at router.js:668:7
    at Array.forEach (<anonymous>)
    at S (router.js:663:10)
    at y (router.js:595:18)
Xi @ vendor.8a712d83b311029bb0b6.js:672

loadAsync.tsx:28 Error: Absolute route path "/" nested under path "/logs/" is not valid. An absolute child route path must start with the combined path of all its parent routes.
    at o (router.js:270:11)
    at Et (router.js:634:7)
    at router.js:668:7
    at Array.forEach (<anonymous>)
    at S (router.js:663:10)
    at Et (router.js:647:7)
    at router.js:668:7
    at Array.forEach (<anonymous>)
    at S (router.js:663:10)
    at y (router.js:595:18)
(anonymous) @ loadAsync.tsx:28

The API endpoint appears to work without issue.

Expected Behavior

http_publish_uri and http_external_uri (OR GRAYLOG_HTTP_EXTERNAL_URI and GRAYLOG_HTTP_PUBLISH_URI for docker) work as documented and work as they did in previous versions of graylog.

Current Behavior

http_publish_uri and http_external_uri (OR GRAYLOG_HTTP_EXTERNAL_URI and GRAYLOG_HTTP_PUBLISH_URI for docker) no longer allow you to specify an additional path, starting in graylog 5.1.

The API endpoint appears to work without issue.

Possible Solution

Steps to Reproduce (for bugs)

Using the following docker compose file:

services:
  graylog:
    container_name: graydock-graylog
    depends_on:
      mongodb:
        condition: service_started
      opensearch:
        condition: service_started
    deploy:
      resources:
        limits:
          memory: 2g
    entrypoint: /usr/bin/tini -- wait-for-it graydock-opensearch:9200 --  /docker-entrypoint.sh
    environment:
      GRAYLOG_ELASTICSEARCH_HOSTS: http://graydock-opensearch:9200
      GRAYLOG_HTTP_BIND_ADDRESS: 0.0.0.0:9000
      GRAYLOG_HTTP_EXTERNAL_URI: http://localhost:9000/logs/
      GRAYLOG_HTTP_PUBLISH_URI: http://localhost:9000/logs/
      GRAYLOG_IS_MASTER: true
      GRAYLOG_MONGODB_URI: mongodb://graydock-mongo:27017/graylog
      GRAYLOG_PASSWORD_SECRET: ${GRAYLOG_PASSWORD_SECRET}
      GRAYLOG_REPORT_DISABLE_SANDBOX: 'true'
      GRAYLOG_ROOT_PASSWORD_SHA2: ${GRAYLOG_ROOT_PASSWORD_SHA2}
      GRAYLOG_ROOT_TIMEZONE: America/Chicago
      GRAYLOG_SERVER_JAVA_OPTS: -Xms1g -Xmx1g -Dlog4j2.formatMsgNoLookups=true -Djdk.tls.acknowledgeCloseNotify=true
        -XX:+UnlockExperimentalVMOptions -XX:NewRatio=1 -XX:MaxMetaspaceSize=256m
        -server -XX:+ResizeTLAB -XX:-OmitStackTraceInFastThrow
    image: graylog/graylog-enterprise:5.1
    ports:
    - 5044:5044/tcp
    - 5140:5140/tcp
    - 5140:5140/udp
    - 5555:5555/tcp
    - 5555:5555/udp
    - 9000:9000/tcp
    - 12201:12201/tcp
    - 12201:12201/udp
    - 13301:13301/tcp
    - 13302:13302/tcp
    restart: unless-stopped
    volumes:
    - ./storage/graydock-graylog/graylog_journal:/usr/share/graylog/data/journal
    - ./storage/graydock-graylog/contentpacks:/usr/share/graylog/data/contentpacks
  mongodb:
    container_name: graydock-mongo
    deploy:
      resources:
        limits:
          memory: 256m
    image: mongo:6.0
    ports:
    - 27021:27017
    restart: unless-stopped
    volumes:
    - ./storage/graydock-mongo/mongodb:/data/db
  opensearch:
    container_name: graydock-opensearch
    environment:
      DISABLE_INSTALL_DEMO_CONFIG: 'true'
      DISABLE_SECURITY_PLUGIN: 'true'
      OPENSEARCH_JAVA_OPTS: -Xms2g -Xmx2g -Dlog4j2.formatMsgNoLookups=true
      action.auto_create_index: 'false'
      bootstrap.memory_lock: 'true'
      discovery.type: single-node
      http.host: 0.0.0.0
    image: opensearchproject/opensearch:2.5.0
    ports:
    - 9200:9200
    - 9300:9300
    restart: unless-stopped
    ulimits:
      memlock:
        hard: -1
        soft: -1
      nofile:
        hard: 65536
        soft: 65536
    volumes:
    - ./storage/graydock-opensearch/opensearchdata:/usr/share/opensearch/data
version: '3.8'

Observe that you are unable to use the graylog web interface.

Context

Originally reported via https://community.graylog.org/t/graylog-5-1-does-not-load-ui-when-http-external-uri-contains-a-path-sufix/28830?u=drewmiranda-gl

Your Environment

johnnymnemonic84 commented 1 year ago

Same issue upgrading from 5.0 to 5.1, on Debian with LXC and Apache as reverse proxy configured with

<Location /graylog> RequestHeader set X-Graylog-Server-URL "https://graylog.corp.beghelli.it/graylog/" ProxyPass http://graylog:9000 ProxyPassReverse http://graylog:9000

only the login page works, after that the browser responds with

Loading component failed: Absolute route path "/" nested under path "/graylog/" is not valid. An absolute child route path must start with the combined path of all its parent routes.

In server.conf http_publish_uri and http_external_uri are not setted

Connecting directly to the container on port 9000 it works fine

bdovaz commented 1 year ago

@dennisoelkers do you know when there will be a 5.1.x release with this fix? Thanks.

I see that the branch has been merged and in our case we use the Docker image which is where we are being affected.

bernd commented 1 year ago

@bdovaz We released 5.1.1 today. The image should be available on Docker Hub. (release announcement is pending)

drewmiranda-gl commented 1 year ago

Tested and confirmed this is resolved in 5.1.1