Error 404 for Artifactory only when accessed via Traefik

The Artifactory docker container uses port 8081 for its API and 8082 for its web UI. If I expose both ports and access the web UI using localhost:8081 it redirects to localhost:8082/ui just fine and the app works as expected. However, when Traefik is placed in front as my reverse proxy, my Traefik configuration efforts seem to always result in the redirect resulting in an "HTTP Status 404 - Not Found" page. My build system and several other services work fine accessed via Traefik. Here is my current configuration:

traefik:
    image: docker.xenonet.com/traefik:1.7.12-alpine
    build:
      context: .
      dockerfile: ./images/docker-traefik/Dockerfile
      args:
        - VERSION=1.7.12-alpine
    # command: --logLevel=DEBUG
    container_name: traefik
    ports:
      - "8080:8080" # Please read: https://docs.traefik.io/configuration/api/#security
      - "443:443"
      - "80:80"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    networks:
      - buildsys

artifactory:
    image: docker.bintray.io/jfrog/artifactory-cpp-ce:latest
    container_name: artifactory
    ports:
      - "8081:8081"
      - "8082:8082"
    # volumes:
    #   - artifactory-data:/var/opt/jfrog/artifactory
    networks:
      - buildsys
    labels:
      # - "traefik.api.backend=artifactory-api"
      # - "traefik.api.port=8081"
      # - "traefik.api.frontend.entryPoints=http,https"
      # - "traefik.api.frontend.rule=Host:artifactory.example.com"
      - "traefik.ui.backend=artifactory-ui"
      - "traefik.ui.port=8081"
      - "traefik.ui.frontend.entryPoints=http,https"
      - "traefik.ui.frontend.rule=Host:artifactory.example.com"

Hi @aflorence

I believe that Artifactory requires some additional configurationto run behind a reverse proxy, check their documentation.

In case anyone else runs into it. As @cakiwi said some additional configuration is needed behind a reverse proxy. See Traefik as a Reverse Proxy For Artifactory 7.x | by Liejun Tao | Medium for more details. Below is my working labels, ensure that your entrypoints and middlewares match what you have configured.


      labels:
        - "traefik.enable=true"
        - "traefik.docker.network=cloud-public"
        # Artifactory on traefik: https://liejuntao001.medium.com/traefik-as-a-reverse-proxy-for-artifactory-7-x-cb135172d89d
        # artifactory 8082 port
        - "traefik.http.services.artifactory.loadbalancer.server.port=8082"
        # artifactory 8081 port
        - "traefik.http.services.artifactoryApi.loadbalancer.server.port=8081"
        # artifactory UI route
        - "traefik.http.routers.artifactory.service=artifactory"
        - "traefik.http.routers.artifactory.rule=Host(`${DOMAIN?Variable not set}`,`${DOMAIN2?Variable not set}`)"
        - "traefik.http.routers.artifactory.entrypoints=https"
        # artifactory api route
        - "traefik.http.routers.artifactoryApi.service=artifactoryApi"
        - "traefik.http.routers.artifactoryApi.rule=(Host(`${DOMAIN?Variable not set}`,`${DOMAIN2?Variable not set}`) && PathPrefix(`/artifactory{regex:|/.+}`))"
        - "traefik.http.routers.artifactoryApi.entrypoints=https"
        # rewrite for /ui/
        - "traefik.http.middlewares.artifact_uiRedirect.replacepathregex.regex=^/$$"
        - "traefik.http.middlewares.artifact_uiRedirect.replacepathregex.replacement=/ui/"
        - "traefik.http.middlewares.artifact_uiLongRedirect.replacepathregex.regex=^/ui(/)?$$"
        - "traefik.http.middlewares.artifact_uiLongRedirect.replacepathregex.replacement=/ui/"
        # apply the middlewares
        - "traefik.http.routers.artifactory.middlewares=securityHeaders@file,artifact_uiRedirect,artifact_uiLongRedirect"
        - "traefik.http.routers.artifactoryApi.middlewares=securityHeaders@file"
1 Like