Wiki: Traefik and Wikijs

Created on 22 Jan 2020  路  4Comments  路  Source: Requarks/wiki

Question
Hi,

I have installed wikijs with Docker and I can run it normally inside my network, but if I access trough Traefik proxy I get a "Bad Gateway" error.

My Traefik is running other Docker instances with no issues. Here's my configuration:

Host Info (please complete the following information):
OS: Centos 8, Docker
Wiki.js version: 2.0.12
Database engine: MariaDB 10.4.10
Traefik version: 1.7.16
Traefik labels:

  • "traefik.enable=true"

    • "traefik.backend=wikijs"

    • "traefik.frontend.rule=Host:wiki.${DOMAINNAME}"

    • "traefik.port=9093" #redirected in Wikijs' in docker-compose to 3000

    • "traefik.docker.network=traefik_proxy"

    • "traefik.frontend.headers.SSLRedirect=true"

    • "traefik.frontend.headers.STSSeconds=315360000"

    • "traefik.frontend.headers.browserXSSFilter=true"

    • "traefik.frontend.headers.contentTypeNosniff=true"

    • "traefik.frontend.headers.forceSTSHeader=true"

    • "traefik.frontend.headers.SSLHost=example.com"

    • "traefik.frontend.headers.STSIncludeSubdomains=true"

    • "traefik.frontend.headers.STSPreload=true"

    • "traefik.frontend.headers.customFrameOptionsValue: allow-from https:${DOMAINNAME}"

    • "traefik.frontend.auth.forward.address=http://oauth:4181"

    • "traefik.frontend.auth.forward.authResponseHeaders=X-Forwarded-User"

    • "traefik.frontend.auth.forward.trustForwardHeader=true"

help

All 4 comments

Make sure wiki.is runs properly without a reverse proxy first, then add Traefik. Error 502 simply means Wiki.js cannot be reached, most likely due to an incorrect configuration. Check the logs of wiki container and you'll quickly find out the issue.

@gruesomehit For the record, It works like a charm for me (HTTP and HTTPS)
Traefik + Wiki js
This is my compose

version: "3"
services:
  db:
    image: postgres:11-alpine
    environment:
      POSTGRES_DB: XXXXXXXXXX
      POSTGRES_PASSWORD: XXXXXXXXXX
      POSTGRES_USER: XXXXXXXXXX
    logging:
      driver: "none"
    restart: unless-stopped
    networks:
      - internal
    labels:
     - traefik.enable=false
    volumes:
      - db-data:/var/lib/postgresql/data
  wiki:
    image: requarks/wiki:2.0.12
    depends_on:
      - db
    environment:
      DB_TYPE: postgres
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: wikijs
      DB_PASS: XXXXXXXXXX
      DB_NAME: XXXXXXXXXX
    restart: unless-stopped
    ports:
      - 3000
    labels:
      - traefik.backend=wikijs
      - traefik.frontend.rule=Host:MY.WIKI.TLD
      - traefik.docker.network=proxy
      - traefik.port=3000
    networks:
      - internal
      - proxy
volumes:
  db-data:
networks:
  proxy:
    external: true
  internal:
    external: false

I have 2 Network (always, for each compose)

  • 1 Proxy on the exposed Contenaire. It's the network for traefik
  • 1 Internal, for the current compose stack.

As skapin suggest I made me a mess with the Traefik network. The traefik.port label must be always 3000

Here you can see a good example what I say:

https://stackoverflow.com/questions/49417889/traefik-bad-gateway-error-502-for-some-containers

I'll rewrite my docker-compose file about both networks taking your compose file as a good example.

Thanks everyone for your kindly help.

Was this page helpful?
0 / 5 - 0 ratings