Traefik. Прокси к другому бэкэнду - PullRequest
0 голосов
/ 07 января 2020

Если я обращаюсь к domain.com/api/v0/add, я получаю ожидаемый результат, но если я говорю по адресу domain.com/ipfs, тогда получаю 404 .

Как проксировать все звонки, начиная с способа / ipfs ??

Я кратко изучил документацию traefik, но так и не нашел ответа.

У меня docker-compose.yml файл:

version: '3.4'

volumes:
  traefik: {}

services:

  ipfs0:
    container_name: ipfs0
    image: ipfs/go-ipfs:release
    ports:
          - "4001:4001"
          - "5001:5001"
          - "8080:8080"
    volumes:
      - ./compose/ipfs0:/data/ipfs

  ipfs1:
    container_name: ipfs1
    image: ipfs/go-ipfs:release
    ports:
          - "4101:4001" # ipfs swarm
          - "5101:5001" # expose if needed/wanted
          - "8180:8080" # exposes if needed/wanted
    volumes:
      - ./compose/ipfs1:/data/ipfs

  traefik:
    build:
      context: .
      dockerfile: ./compose/traefik/Dockerfile
    depends_on:
      - ipfs0
    volumes:
      - traefik:/etc/traefik/acme
    ports:
      - "0.0.0.0:80:80"
      - "0.0.0.0:443:443"

и traefik.toml файл

logLevel = "INFO"
defaultEntryPoints = ["http", "https"]

# Entrypoints, http and https
[entryPoints]
  # http should be redirected to https
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  # https is the default
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

# Enable ACME (Let's Encrypt): automatic SSL
[acme]
# Email address used for registration
email = "*******************@gmail.com"
storage = "/etc/traefik/acme/acme.json"
entryPoint = "https"
onDemand = false
OnHostRule = true
  # Use a HTTP-01 acme challenge rather than TLS-SNI-01 challenge
  [acme.httpChallenge]
  entryPoint = "http"

[file]
[backends]
  [backends.ipfs0]
    [backends.ipfs0.servers.server1]
      path = "/api"
      url = "http://ipfs0:5001"
  [backends.ipfs1]
    [backends.ipfs1.servers.server1]
      path = "/ipfs"
      url = "http://ipfs1:8180"

[frontends]
  [frontends.ipfs0]
    backend = "ipfs0"
    passHostHeader = truea
    [frontends.ipfs0.routes.dr1]
      rule = "Host:domain.com"
  [frontends.ipfs1]
    backend = "ipfs1"
    passHostHeader = true
    [frontends.ipfs1.routes.dr1]
      rule = "Host:domain.com"
...