This commit is contained in:
emile 2015-09-14 11:01:47 +02:00
parent 6c5c3cbbb0
commit e983bbe3e3
5 changed files with 93 additions and 34 deletions

107
README.md
View file

@ -1,9 +1,11 @@
# /Træfɪk/ ![/Træfɪk/](docs/img/traefik.logo.png "/Træfɪk/")
/Træfɪk/ is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease. /Træfɪk/ is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease.
It supports several backends (Docker, Mesos/Marathon, Consul, Etcd, Rest API, file...) to manage its configuration automatically and dynamically (hot-reload). It supports several backends (Docker, Mesos/Marathon, Consul, Etcd, Rest API, file...) to manage its configuration automatically and dynamically (hot-reload).
## Features ![Backends](docs/img/backends.png "Backends")
# Features
* No dependency hell, single binary made with go * No dependency hell, single binary made with go
* Simple json Rest API * Simple json Rest API
@ -17,14 +19,14 @@ It supports several backends (Docker, Mesos/Marathon, Consul, Etcd, Rest API, fi
* SSL backends support * SSL backends support
* SSL frontend support * SSL frontend support
## Plumbing # Plumbing
* [Oxy](https://github.com/mailgun/oxy/): an awsome proxy librarymade by Mailgun guys * [Oxy](https://github.com/mailgun/oxy/): an awsome proxy library made by Mailgun guys
* [Gorilla mux](https://github.com/gorilla/mux): famous request router * [Gorilla mux](https://github.com/gorilla/mux): famous request router
* [Negroni](https://github.com/codegangsta/negroni): web middlewares made simple * [Negroni](https://github.com/codegangsta/negroni): web middlewares made simple
* [Graceful](https://github.com/tylerb/graceful): graceful shutdown of http.Handler servers * [Graceful](https://github.com/tylerb/graceful): graceful shutdown of http.Handler servers
## Quick start # Quick start
* The simple way: go to the [releases](https://github.com/emilevauge/traefik/releases) page and get a binary. * The simple way: go to the [releases](https://github.com/emilevauge/traefik/releases) page and get a binary.
* Or simply execute: * Or simply execute:
@ -38,11 +40,30 @@ go get github.com/emilevauge/traefik
./traefik traefik.toml ./traefik traefik.toml
``` ```
## Configuration # Configuration
Here is a sample configuration TOML file: ## Global configuration
```toml ```toml
# traefik.toml
port = ":80"
graceTimeOut = 10
logLevel = "DEBUG"
traefikLogsStdout = true
# traefikLogsFile = "log/traefik.log"
# accessLogsFile = "log/access.log"
# CertFile = "traefik.crt"
# KeyFile = "traefik.key"
```
## File backend
Like any other reverse proxy, /Træfɪk/ can be configured with a file. You have two choices:
* simply add your configuration at the end of the global configuration file ```traefik.tml``` :
```toml
# traefik.toml
port = ":80" port = ":80"
graceTimeOut = 10 graceTimeOut = 10
logLevel = "DEBUG" logLevel = "DEBUG"
@ -52,25 +73,7 @@ traefikLogsStdout = true
# CertFile = "traefik.crt" # CertFile = "traefik.crt"
# KeyFile = "traefik.key" # KeyFile = "traefik.key"
[web] [file]
address = ":8080"
# [docker]
# endpoint = "unix:///var/run/docker.sock"
# watch = true
# domain = "localhost"
# filename = "docker.tmpl"
# [marathon]
# endpoint = "http://127.0.0.1:8080"
# networkInterface = "eth0"
# watch = true
# domain = "localhost"
# filename = "marathon.tmpl"
# [file]
# filename = "rules.toml"
# watch = true
[backends] [backends]
[backends.backend1] [backends.backend1]
@ -98,3 +101,55 @@ address = ":8080"
value = "/test" value = "/test"
``` ```
* or put your configuration in a separate file, for example ```rules.tml```:
```toml
# traefik.toml
port = ":80"
graceTimeOut = 10
logLevel = "DEBUG"
traefikLogsStdout = true
# traefikLogsFile = "log/traefik.log"
# accessLogsFile = "log/access.log"
# CertFile = "traefik.crt"
# KeyFile = "traefik.key"
[file]
filename = "rules.toml"
```
```toml
# rules.toml
[backends]
[backends.backend1]
[backends.backend1.servers.server1]
url = "http://172.17.0.2:80"
weight = 10
[backends.backend1.servers.server2]
url = "http://172.17.0.3:80"
weight = 1
[backends.backend2]
[backends.backend2.servers.server1]
url = "http://172.17.0.4:80"
weight = 1
[routes]
[routes.route1]
backend = "backend2"
[routes.route1.rules.test1]
category = "Host"
value = "test.localhost"
[routes.route2]
backend = "backend1"
[routes.route2.rules.test2]
category = "Path"
value = "/test"
```
If you want /Træfɪk/ to watch file changes automatically, just add:
```toml
[file]
watch = true
```

View file

@ -1,5 +1,6 @@
# /træfɪk/ # /Træfɪk/
* Add traefik.protocol label
* Providers recovery * Providers recovery
* tls client verification * tls client verification
* Default configuration values * Default configuration values

BIN
docs/img/backends.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
docs/img/traefik.logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -2,7 +2,7 @@ port = ":8001"
graceTimeOut = 10 graceTimeOut = 10
# traefikLogsFile = "log/traefik.log" # traefikLogsFile = "log/traefik.log"
traefikLogsStdout = true traefikLogsStdout = true
# accessLogsFile = "log/access.log" accessLogsFile = "log/access.log"
logLevel = "DEBUG" logLevel = "DEBUG"
# CertFile = "traefik.crt" # CertFile = "traefik.crt"
# KeyFile = "traefik.key" # KeyFile = "traefik.key"
@ -10,7 +10,7 @@ logLevel = "DEBUG"
[docker] [docker]
endpoint = "unix:///var/run/docker.sock" endpoint = "unix:///var/run/docker.sock"
watch = true watch = true
domain = "toto.fr" domain = "localhost"
# filename = "docker.tmpl" # filename = "docker.tmpl"
# [marathon] # [marathon]
@ -23,9 +23,9 @@ domain = "toto.fr"
[web] [web]
address = ":8010" address = ":8010"
# [file] #[file]
# filename = "rules.toml" # filename = "rules.toml"
# watch = true watch = true
[backends] [backends]
[backends.backend1] [backends.backend1]
@ -37,15 +37,18 @@ address = ":8010"
weight = 1 weight = 1
[backends.backend2] [backends.backend2]
[backends.backend2.servers.server1] [backends.backend2.servers.server1]
url = "http://172.17.0.2:80" url = "https://www.google.fr"
weight = 100 weight = 1
[backends.backend2.servers.server2]
url = "http://www.wikipedia.fr"
weight = 2
[routes] [routes]
[routes.route1] [routes.route1]
backend = "backend2" backend = "backend2"
[routes.route1.rules.test_zenika_1] [routes.route1.rules.test_zenika_1]
category = "Host" category = "Host"
value = "test.zenika.fr" value = "test.localhost"
[routes.route2] [routes.route2]
backend = "backend1" backend = "backend1"
[routes.route2.rules.test_zenika_2] [routes.route2.rules.test_zenika_2]