Skip to content

seamapi/node-traefik

Repository files navigation

Node Traefik (traefik)

Traefik (pronounced traffic) is a modern HTTP reverse proxy and load balancer that makes deploying microservices easy

Use traefik as an npm module for tighter integration with node apps.

Usage

npm install traefik

const traefik = require("traefik")

// Path to YAML/TOML
let service = await traefik.start("/path/to/traefik.yml")

// Static Config Only
service = await traefik.start({
  defaultEntryPoints: ["http"],
  entryPoints: {
    http: {
      address: ":3001",
    },
  },
  "log.level": "DEBUG",
})

// Long Form
service = await traefik.start({
  log: true,
  staticConfig: {
    defaultEntryPoints: ["http"],
    entryPoints: {
      http: {
        address: ":3001",
      },
    },
    // dot notation is also OK!
    "log.level": "DEBUG",
  },
  dynamicConfig: {
    http: {
      routers: {
        someRouter: {
          service: "someService",
          rule: "PathPrefix(`/`)",
        },
      },
      services: {
        someService: {
          "loadBalancer.servers": [{ url: "http://localhost:3000" }],
        },
      },
    },
  },
})

await service.stop()

Options

See the traefik static configuration and dynamic configuration reference pages.

About

An NPM module for interfacing traefik. Easily reverse proxies and load balancers.

Resources

License

Stars

Watchers

Forks

Packages

No packages published