mirror of
https://github.com/containous/traefik.git
synced 2025-09-07 09:44:23 +03:00
Compare commits
67 Commits
v1.0.alpha
...
v1.0.alpha
Author | SHA1 | Date | |
---|---|---|---|
|
6e1a0554c0 | ||
|
ae73d08d67 | ||
|
ddceefa4e1 | ||
|
80cd6c3699 | ||
|
9cfd0a6b26 | ||
|
1e99ecf583 | ||
|
aae7941689 | ||
|
d888b4fcb5 | ||
|
b029e7eded | ||
|
6f3afe8213 | ||
|
b4c019afb6 | ||
|
143ea86ab9 | ||
|
287d5c59da | ||
|
ae6bda3220 | ||
|
0a6be92290 | ||
|
b71b5dd0d4 | ||
|
b12c4ac55a | ||
|
9f736f4235 | ||
|
b59c54d560 | ||
|
0429faf65d | ||
|
33d912290b | ||
|
d390f86de2 | ||
|
aaeb7cdffd | ||
|
32bfecff83 | ||
|
d671cc3821 | ||
|
5dea2e7902 | ||
|
1fdff9dae4 | ||
|
46d7cc83c9 | ||
|
539fd5bafc | ||
|
e8eec77df4 | ||
|
9a8d30a0b8 | ||
|
812ff77cec | ||
|
86f95924a9 | ||
|
a0df7ab921 | ||
|
2e5f4598f0 | ||
|
46e162e6a9 | ||
|
fd234c683c | ||
|
67bc87dcda | ||
|
c452fd2195 | ||
|
8f38337757 | ||
|
5454299bf0 | ||
|
80f4884d50 | ||
|
4ea48c2d19 | ||
|
37438a6395 | ||
|
784dc9ea62 | ||
|
6362b1da7f | ||
|
31c7aba8c4 | ||
|
45ea23ecc1 | ||
|
661ac977d3 | ||
|
c11cf801ca | ||
|
adca5dc55b | ||
|
641638ba3e | ||
|
fb7457eba0 | ||
|
ddf1922eba | ||
|
13f621a9ed | ||
|
74c5562c2b | ||
|
09320b99f9 | ||
|
a422f775e6 | ||
|
facc936fe4 | ||
|
28458345b4 | ||
|
398dfbd8a5 | ||
|
3a877a51b9 | ||
|
5a979b3dd6 | ||
|
f89b727ad1 | ||
|
781c6aaafa | ||
|
f126e7585d | ||
|
27eae04e87 |
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
||||
dist/
|
||||
vendor/
|
||||
!dist/traefik
|
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,5 +6,4 @@ log
|
||||
traefik
|
||||
traefik.toml
|
||||
|
||||
Godeps/_workspace/bin
|
||||
Godeps/_workspace/pkg
|
||||
vendor/
|
||||
|
302
Godeps/Godeps.json
generated
302
Godeps/Godeps.json
generated
@@ -1,302 +0,0 @@
|
||||
{
|
||||
"ImportPath": "github.com/emilevauge/traefik",
|
||||
"GoVersion": "go1.4.2",
|
||||
"Packages": [
|
||||
"./..."
|
||||
],
|
||||
"Deps": [{
|
||||
"ImportPath": "github.com/BurntSushi/toml",
|
||||
"Rev": "bd2bdf7f18f849530ef7a1c29a4290217cab32a1"
|
||||
}, {
|
||||
"ImportPath": "github.com/BurntSushi/ty",
|
||||
"Rev": "6add9cd6ad42d389d6ead1dde60b4ad71e46fd74"
|
||||
}, {
|
||||
"ImportPath": "github.com/Sirupsen/logrus",
|
||||
"Comment": "v0.8.7",
|
||||
"Rev": "418b41d23a1bf978c06faea5313ba194650ac088"
|
||||
}, {
|
||||
"ImportPath": "github.com/alecthomas/template",
|
||||
"Rev": "b867cc6ab45cece8143cfcc6fc9c77cf3f2c23c0"
|
||||
}, {
|
||||
"ImportPath": "github.com/alecthomas/units",
|
||||
"Rev": "6b4e7dc5e3143b85ea77909c72caf89416fc2915"
|
||||
}, {
|
||||
"ImportPath": "github.com/boltdb/bolt",
|
||||
"Rev": "51f99c862475898df9773747d3accd05a7ca33c1"
|
||||
}, {
|
||||
"ImportPath": "github.com/cenkalti/backoff",
|
||||
"Rev": "4dc77674aceaabba2c7e3da25d4c823edfb73f99"
|
||||
}, {
|
||||
"ImportPath": "github.com/codahale/hdrhistogram",
|
||||
"Rev": "954f16e8b9ef0e5d5189456aa4c1202758e04f17"
|
||||
}, {
|
||||
"ImportPath": "github.com/codegangsta/negroni",
|
||||
"Comment": "v0.1-70-gc7477ad",
|
||||
"Rev": "c7477ad8e330bef55bf1ebe300cf8aa67c492d1b"
|
||||
}, {
|
||||
"ImportPath": "github.com/coreos/go-etcd/etcd",
|
||||
"Comment": "v2.0.0-11-gcc90c7b",
|
||||
"Rev": "cc90c7b091275e606ad0ca7102a23fb2072f3f5e"
|
||||
}, {
|
||||
"ImportPath": "github.com/davecgh/go-spew/spew",
|
||||
"Rev": "2df174808ee097f90d259e432cc04442cf60be21"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libkv",
|
||||
"Rev": "3732f7ff1b56057c3158f10bceb1e79133025373"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/distribution",
|
||||
"Comment": "v2.0.0-467-g9038e48",
|
||||
"Rev": "9038e48c3b982f8e82281ea486f078a73731ac4e"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/api",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/cliconfig",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/daemon/network",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/graph/tags",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/image",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/opts",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/archive",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/fileutils",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/homedir",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/httputils",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/ioutils",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/jsonmessage",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/mflag",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/nat",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/parsers",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/pools",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/promise",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/random",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/stdcopy",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/stringid",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/symlink",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/system",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/tarsum",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/term",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/timeutils",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/tlsconfig",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/ulimit",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/units",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/urlutil",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/useragent",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/pkg/version",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/registry",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/runconfig",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/utils",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/docker/volume",
|
||||
"Comment": "v1.4.1-5200-gf39987a",
|
||||
"Rev": "f39987afe8d611407887b3094c03d6ba6a766a67"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/docker",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/logger",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/lookup",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/project",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libcompose/utils",
|
||||
"Rev": "aad672800904307e96a2c21cad1420f3080e0f35"
|
||||
}, {
|
||||
"ImportPath": "github.com/docker/libtrust",
|
||||
"Rev": "9cbd2a1374f46905c68a4eb3694a130610adc62a"
|
||||
}, {
|
||||
"ImportPath": "github.com/elazarl/go-bindata-assetfs",
|
||||
"Rev": "d5cac425555ca5cf00694df246e04f05e6a55150"
|
||||
}, {
|
||||
"ImportPath": "github.com/flynn/go-shlex",
|
||||
"Rev": "3f9db97f856818214da2e1057f8ad84803971cff"
|
||||
}, {
|
||||
"ImportPath": "github.com/fsouza/go-dockerclient",
|
||||
"Rev": "0239034d42f665efa17fd77c39f891c2f9f32922"
|
||||
}, {
|
||||
"ImportPath": "github.com/gambol99/go-marathon",
|
||||
"Rev": "0ba31bcb0d7633ba1888d744c42990eb15281cf1"
|
||||
}, {
|
||||
"ImportPath": "github.com/gorilla/context",
|
||||
"Rev": "215affda49addc4c8ef7e2534915df2c8c35c6cd"
|
||||
}, {
|
||||
"ImportPath": "github.com/gorilla/handlers",
|
||||
"Rev": "40694b40f4a928c062f56849989d3e9cd0570e5f"
|
||||
}, {
|
||||
"ImportPath": "github.com/gorilla/mux",
|
||||
"Rev": "f15e0c49460fd49eebe2bcc8486b05d1bef68d3a"
|
||||
}, {
|
||||
"ImportPath": "github.com/hashicorp/consul/api",
|
||||
"Comment": "v0.5.2-313-gde08067",
|
||||
"Rev": "de080672fee9e6104572eeea89eccdca135bb918"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/log",
|
||||
"Rev": "44874009257d4d47ba9806f1b7f72a32a015e4d8"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/manners",
|
||||
"Comment": "0.3.1-30-g37136f7",
|
||||
"Rev": "37136f736785d7c6aa3b9a27b4b2dd1028ca6d79"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/oxy/cbreaker",
|
||||
"Rev": "547c334d658398c05b346c0b79d8f47ba2e1473b"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/oxy/forward",
|
||||
"Rev": "547c334d658398c05b346c0b79d8f47ba2e1473b"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/oxy/memmetrics",
|
||||
"Rev": "547c334d658398c05b346c0b79d8f47ba2e1473b"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/oxy/roundrobin",
|
||||
"Rev": "547c334d658398c05b346c0b79d8f47ba2e1473b"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/oxy/utils",
|
||||
"Rev": "547c334d658398c05b346c0b79d8f47ba2e1473b"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/predicate",
|
||||
"Rev": "cb0bff91a7ab7cf7571e661ff883fc997bc554a3"
|
||||
}, {
|
||||
"ImportPath": "github.com/mailgun/timetools",
|
||||
"Rev": "fd192d755b00c968d312d23f521eb0cdc6f66bd0"
|
||||
}, {
|
||||
"ImportPath": "github.com/samuel/go-zookeeper/zk",
|
||||
"Rev": "fa6674abf3f4580b946a01bf7a1ce4ba8766205b"
|
||||
}, {
|
||||
"ImportPath": "github.com/opencontainers/runc/libcontainer/user",
|
||||
"Comment": "v0.0.4-21-g4ab1324",
|
||||
"Rev": "4ab132458fc3e9dbeea624153e0331952dc4c8d5"
|
||||
}, {
|
||||
"ImportPath": "github.com/samalba/dockerclient",
|
||||
"Rev": "cfb489c624b635251a93e74e1e90eb0959c5367f"
|
||||
}, {
|
||||
"ImportPath": "github.com/thoas/stats",
|
||||
"Rev": "54ed61c2b47e263ae2f01b86837b0c4bd1da28e8"
|
||||
}, {
|
||||
"ImportPath": "github.com/unrolled/render",
|
||||
"Rev": "26b4e3aac686940fe29521545afad9966ddfc80c"
|
||||
}, {
|
||||
"ImportPath": "github.com/vdemeester/shakers",
|
||||
"Rev": "8fe734f75f3a70b651cbfbf8a55a009da09e8dc5"
|
||||
}, {
|
||||
"ImportPath": "golang.org/x/net/context",
|
||||
"Rev": "d9558e5c97f85372afee28cf2b6059d7d3818919"
|
||||
}, {
|
||||
"ImportPath": "gopkg.in/alecthomas/kingpin.v2",
|
||||
"Comment": "v2.0.12",
|
||||
"Rev": "639879d6110b1b0409410c7b737ef0bb18325038"
|
||||
}, {
|
||||
"ImportPath": "gopkg.in/check.v1",
|
||||
"Rev": "11d3bc7aa68e238947792f30573146a3231fc0f1"
|
||||
}, {
|
||||
"ImportPath": "gopkg.in/fsnotify.v1",
|
||||
"Comment": "v1.2.0",
|
||||
"Rev": "96c060f6a6b7e0d6f75fddd10efeaca3e5d1bcb0"
|
||||
}, {
|
||||
"ImportPath": "gopkg.in/mgo.v2/bson",
|
||||
"Comment": "r2015.06.03-5-g22287ba",
|
||||
"Rev": "22287bab4379e1fbf6002fb4eb769888f3fb224c"
|
||||
}, {
|
||||
"ImportPath": "gopkg.in/yaml.v2",
|
||||
"Rev": "7ad95dd0798a40da1ccdff6dff35fd177b5edf40"
|
||||
}]
|
||||
}
|
5
Godeps/Readme
generated
5
Godeps/Readme
generated
@@ -1,5 +0,0 @@
|
||||
This directory tree is generated automatically by godep.
|
||||
|
||||
Please do not edit.
|
||||
|
||||
See https://github.com/tools/godep for more information.
|
3
Godeps/_workspace/.gitignore
generated
vendored
3
Godeps/_workspace/.gitignore
generated
vendored
@@ -1,3 +0,0 @@
|
||||
/pkg
|
||||
/bin
|
||||
/src
|
12
Godeps/_workspace/src/github.com/docker/docker/autogen/dockerversion/dockerversion.go
generated
vendored
12
Godeps/_workspace/src/github.com/docker/docker/autogen/dockerversion/dockerversion.go
generated
vendored
@@ -1,12 +0,0 @@
|
||||
// AUTOGENERATED FILE; see ./hack/make/.go-autogen
|
||||
package dockerversion
|
||||
|
||||
var (
|
||||
GITCOMMIT string = ""
|
||||
VERSION string = ""
|
||||
BUILDTIME string = ""
|
||||
|
||||
IAMSTATIC string = "true"
|
||||
INITSHA1 string = ""
|
||||
INITPATH string = ""
|
||||
)
|
3
Makefile
3
Makefile
@@ -20,6 +20,9 @@ print-%: ; @echo $*=$($*)
|
||||
|
||||
default: binary
|
||||
|
||||
all: build
|
||||
$(DOCKER_RUN_TRAEFIK) ./script/make.sh
|
||||
|
||||
binary: build
|
||||
$(DOCKER_RUN_TRAEFIK) ./script/make.sh generate binary
|
||||
|
||||
|
75
README.md
75
README.md
@@ -1,9 +1,9 @@
|
||||

|
||||
___
|
||||
|
||||
[](https://circleci.com/gh/EmileVauge/traefik)
|
||||
[](https://circleci.com/gh/emilevauge/traefik)
|
||||
[](https://github.com/EmileVauge/traefik/blob/master/LICENSE.md)
|
||||
[](https://gitter.im/EmileVauge/traefik?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://traefik.herokuapp.com)
|
||||
|
||||
|
||||
Træfɪk is a modern HTTP reverse proxy and load balancer made to deploy microservices with ease.
|
||||
@@ -25,7 +25,8 @@ It supports several backends ([Docker :whale:](https://www.docker.com/), [Mesos/
|
||||
- Tiny docker image included
|
||||
- SSL backends support
|
||||
- SSL frontend support
|
||||
- WebUI
|
||||
- Clean AngularJS Web UI
|
||||
- Websocket support
|
||||
|
||||
## Demo
|
||||
|
||||
@@ -33,6 +34,13 @@ Here is a demo of Træfɪk using Docker backend, showing a load-balancing betwee
|
||||
|
||||
[](https://asciinema.org/a/4tcyde7riou5vxulo6my3mtko)
|
||||
|
||||
## Web UI
|
||||
|
||||
You can access to a simple HTML frontend of Træfik.
|
||||
|
||||

|
||||

|
||||
|
||||
## Plumbing
|
||||
|
||||
- [Oxy](https://github.com/mailgun/oxy/): an awsome proxy library made by Mailgun guys
|
||||
@@ -68,65 +76,62 @@ You can find the complete documentation [here](docs/index.md).
|
||||
|
||||
Refer to the [benchmarks section](docs/index.md#benchmarks) in the documentation.
|
||||
|
||||
## Web UI
|
||||
|
||||
You can access to a simple HTML frontend of Træfik.
|
||||
|
||||

|
||||
|
||||
## Contributing
|
||||
|
||||
### Building
|
||||
|
||||
You need either [Docker](https://github.com/docker/docker) and `make`, or `go` and `godep` in order to build traefik.
|
||||
You need either [Docker](https://github.com/docker/docker) and `make`, or `go` and `glide` in order to build traefik.
|
||||
|
||||
#### Using Docker and Makefile
|
||||
#### Setting up your `go` environment
|
||||
- You need `go` v1.5
|
||||
- You need to set `export GO15VENDOREXPERIMENT=1` environment variable
|
||||
- You need `go-bindata` to be able to use `go generate` command (needed to build) : `go get github.com/jteeuwen/go-bindata/...`.
|
||||
- If you clone Træfɪk into something like `~/go/src/github.com/traefik`, your `GOPATH` variable will have to be set to `~/go`: export `GOPATH=~/go`.
|
||||
|
||||
#### Using `Docker` and `Makefile`
|
||||
|
||||
You need to run the `binary` target. This will create binaries for
|
||||
linux and darwin platforms in the `dist` folder.
|
||||
linux platform in the `dist` folder.
|
||||
|
||||
```bash
|
||||
$ make binary
|
||||
docker build -t "traefik-dev:your-feature-branch" -f build.Dockerfile .
|
||||
# […]
|
||||
docker run --rm -it -e OS_ARCH_ARG -e OS_PLATFORM_ARG -e TESTFLAGS -v "/home/vincent/src/github/vdemeester/traefik/dist:/go/src/github.com/emilevauge/traefik/dist" "traefik-dev:your-feature-branch" ./script/make.sh generate binary
|
||||
docker build -t "traefik-dev:no-more-godep-ever" -f build.Dockerfile .
|
||||
Sending build context to Docker daemon 295.3 MB
|
||||
Step 0 : FROM golang:1.5
|
||||
---> 8c6473912976
|
||||
Step 1 : RUN go get github.com/Masterminds/glide
|
||||
[...]
|
||||
docker run --rm -v "/var/run/docker.sock:/var/run/docker.sock" -it -e OS_ARCH_ARG -e OS_PLATFORM_ARG -e TESTFLAGS -v "/home/emile/dev/go/src/github.com/emilevauge/traefik/"dist":/go/src/github.com/emilevauge/traefik/"dist"" "traefik-dev:no-more-godep-ever" ./script/make.sh generate binary
|
||||
---> Making bundle: generate (in .)
|
||||
removed 'gen.go'
|
||||
|
||||
---> Making bundle: binary (in .)
|
||||
Number of parallel builds: 8
|
||||
|
||||
--> linux/arm: github.com/emilevauge/traefik
|
||||
--> darwin/amd64: github.com/emilevauge/traefik
|
||||
--> darwin/386: github.com/emilevauge/traefik
|
||||
--> linux/386: github.com/emilevauge/traefik
|
||||
--> linux/amd64: github.com/emilevauge/traefik
|
||||
|
||||
$ ls dist/
|
||||
traefik* traefik_darwin-386* traefik_darwin-amd64* traefik_linux-386* traefik_linux-amd64* traefik_linux-arm*
|
||||
traefik*
|
||||
```
|
||||
|
||||
#### Using `godep`
|
||||
#### Using `glide`
|
||||
|
||||
The idea behind `godep` is the following :
|
||||
The idea behind `glide` is the following :
|
||||
|
||||
- when checkout(ing) a project, **run `godep restore`** to install
|
||||
- when checkout(ing) a project, **run `glide up`** to install
|
||||
(`go get …`) the dependencies in the `GOPATH`.
|
||||
- if you need another dependency, `go get` it, import and use it in
|
||||
the source, and **run `godep save ./...`** to save it in
|
||||
`Godeps/Godeps.json`.
|
||||
- if you need another dependency, import and use it in
|
||||
the source, and **run `glide get github.com/Masterminds/cookoo`** to save it in
|
||||
`vendor` and add it to your `glide.yaml`.
|
||||
|
||||
```bash
|
||||
$ godep restore
|
||||
# Generate
|
||||
$ godep go generate
|
||||
$ glide up --update-vendored
|
||||
# generate
|
||||
$ go generate
|
||||
# Simple go build
|
||||
$ godep go build
|
||||
$ go build
|
||||
# Using gox to build multiple platform
|
||||
$ GOPATH=`godep path`:$GOPATH gox "linux darwin" "386 amd64 arm" \
|
||||
$ gox "linux darwin" "386 amd64 arm" \
|
||||
-output="dist/traefik_{{.OS}}-{{.Arch}}"
|
||||
# run other commands like tests
|
||||
$ godep go test ./...
|
||||
$ go test ./...
|
||||
ok _/home/vincent/src/github/vdemeester/traefik 0.004s
|
||||
```
|
||||
|
||||
|
@@ -1,12 +1,16 @@
|
||||
FROM golang:1.5
|
||||
|
||||
RUN go get github.com/tools/godep
|
||||
RUN go get github.com/Masterminds/glide
|
||||
RUN go get github.com/mitchellh/gox
|
||||
RUN go get github.com/tcnksm/ghr
|
||||
RUN go get github.com/jteeuwen/go-bindata/...
|
||||
|
||||
# Which docker version to test on
|
||||
ENV DOCKER_VERSION 1.6.2
|
||||
|
||||
# enable GO15VENDOREXPERIMENT
|
||||
ENV GO15VENDOREXPERIMENT 1
|
||||
|
||||
# Download docker
|
||||
RUN set -ex; \
|
||||
curl https://get.docker.com/builds/Linux/x86_64/docker-${DOCKER_VERSION} -o /usr/local/bin/docker-${DOCKER_VERSION}; \
|
||||
@@ -15,17 +19,9 @@ RUN set -ex; \
|
||||
# Set the default Docker to be run
|
||||
RUN ln -s /usr/local/bin/docker-${DOCKER_VERSION} /usr/local/bin/docker
|
||||
|
||||
ENV PATH /go/src/github.com/emilevauge/traefik/Godeps/_workspace/bin:$PATH
|
||||
|
||||
WORKDIR /go/src/github.com/emilevauge/traefik
|
||||
|
||||
# This is a hack (see libcompose#32) - will be removed when libcompose will be fixed
|
||||
# (i.e go get able)
|
||||
RUN mkdir -p /go/src/github.com/docker/docker/autogen/dockerversion/
|
||||
COPY Godeps/_workspace/src/github.com/docker/docker/autogen/dockerversion/dockerversion.go /go/src/github.com/docker/docker/autogen/dockerversion/dockerversion.go
|
||||
|
||||
RUN mkdir Godeps
|
||||
COPY Godeps/Godeps.json Godeps/
|
||||
RUN godep restore
|
||||
COPY glide.yaml glide.yaml
|
||||
RUN glide up
|
||||
|
||||
COPY . /go/src/github.com/emilevauge/traefik
|
||||
|
10
circle.yml
10
circle.yml
@@ -6,6 +6,8 @@ machine:
|
||||
environment:
|
||||
REPO: $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME
|
||||
DOCKER_HOST: tcp://172.17.42.1:2375
|
||||
MAKE_DOCKER_HOST: $DOCKER_HOST
|
||||
VERSION: v1.0.alpha.$CIRCLE_BUILD_NUM
|
||||
|
||||
dependencies:
|
||||
pre:
|
||||
@@ -18,7 +20,7 @@ dependencies:
|
||||
test:
|
||||
override:
|
||||
- make test-unit
|
||||
- make MAKE_DOCKER_HOST=$DOCKER_HOST test-integration
|
||||
- make test-integration
|
||||
post:
|
||||
- make crossbinary
|
||||
- make image
|
||||
@@ -27,8 +29,8 @@ deployment:
|
||||
hub:
|
||||
branch: master
|
||||
commands:
|
||||
- ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --prerelease v1.0.alpha.$CIRCLE_BUILD_NUM dist/
|
||||
- ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --prerelease ${VERSION} dist/
|
||||
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
|
||||
- docker push ${REPO,,}:latest
|
||||
- docker tag ${REPO,,}:latest ${REPO,,}:v1.0.alpha.$CIRCLE_BUILD_NUM
|
||||
- docker push ${REPO,,}:v1.0.alpha.$CIRCLE_BUILD_NUM
|
||||
- docker tag ${REPO,,}:latest ${REPO,,}:${VERSION}
|
||||
- docker push ${REPO,,}:${VERSION}
|
||||
|
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type GlobalConfiguration struct {
|
||||
@@ -12,6 +13,7 @@ type GlobalConfiguration struct {
|
||||
TraefikLogsFile string
|
||||
CertFile, KeyFile string
|
||||
LogLevel string
|
||||
ProvidersThrottleDuration time.Duration
|
||||
Docker *DockerProvider
|
||||
File *FileProvider
|
||||
Web *WebProvider
|
||||
@@ -28,42 +30,51 @@ func NewGlobalConfiguration() *GlobalConfiguration {
|
||||
globalConfiguration.Port = ":80"
|
||||
globalConfiguration.GraceTimeOut = 10
|
||||
globalConfiguration.LogLevel = "ERROR"
|
||||
globalConfiguration.ProvidersThrottleDuration = time.Duration(2 * time.Second)
|
||||
|
||||
return globalConfiguration
|
||||
}
|
||||
|
||||
// Backend configuration
|
||||
type Backend struct {
|
||||
Servers map[string]Server
|
||||
CircuitBreaker *CircuitBreaker
|
||||
LoadBalancer *LoadBalancer
|
||||
Servers map[string]Server `json:"servers,omitempty"`
|
||||
CircuitBreaker *CircuitBreaker `json:"circuitBreaker,omitempty"`
|
||||
LoadBalancer *LoadBalancer `json:"loadBalancer,omitempty"`
|
||||
}
|
||||
|
||||
// LoadBalancer configuration
|
||||
type LoadBalancer struct {
|
||||
Method string
|
||||
Method string `json:"method,omitempty"`
|
||||
}
|
||||
|
||||
// CircuitBreaker configuration
|
||||
type CircuitBreaker struct {
|
||||
Expression string
|
||||
Expression string `json:"expression,omitempty"`
|
||||
}
|
||||
|
||||
// Server configuration
|
||||
type Server struct {
|
||||
URL string
|
||||
Weight int
|
||||
URL string `json:"url,omitempty"`
|
||||
Weight int `json:"weight,omitempty"`
|
||||
}
|
||||
|
||||
// Route configuration
|
||||
type Route struct {
|
||||
Rule string
|
||||
Value string
|
||||
Rule string `json:"rule,omitempty"`
|
||||
Value string `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// Frontend configuration
|
||||
type Frontend struct {
|
||||
Backend string
|
||||
Routes map[string]Route
|
||||
PassHostHeader bool `json:"passHostHeader,omitempty"`
|
||||
Backend string `json:"backend,omitempty"`
|
||||
Routes map[string]Route `json:"routes,omitempty"`
|
||||
}
|
||||
|
||||
// Configuration of a provider
|
||||
type Configuration struct {
|
||||
Backends map[string]*Backend
|
||||
Frontends map[string]*Frontend
|
||||
Backends map[string]*Backend `json:"backends,omitempty"`
|
||||
Frontends map[string]*Frontend `json:"frontends,omitempty"`
|
||||
}
|
||||
|
||||
// Load Balancer Method
|
||||
@@ -93,3 +104,10 @@ func NewLoadBalancerMethod(loadBalancer *LoadBalancer) (LoadBalancerMethod, erro
|
||||
}
|
||||
|
||||
var ErrInvalidLoadBalancerMethod = errors.New("Invalid method, using default")
|
||||
|
||||
type configMessage struct {
|
||||
providerName string
|
||||
configuration *Configuration
|
||||
}
|
||||
|
||||
type configs map[string]*Configuration
|
||||
|
141
docker.go
141
docker.go
@@ -8,6 +8,7 @@ import (
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"fmt"
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/BurntSushi/ty/fun"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
@@ -22,40 +23,6 @@ type DockerProvider struct {
|
||||
Domain string
|
||||
}
|
||||
|
||||
var DockerFuncMap = template.FuncMap{
|
||||
"getBackend": func(container docker.Container) string {
|
||||
for key, value := range container.Config.Labels {
|
||||
if key == "traefik.backend" {
|
||||
return value
|
||||
}
|
||||
}
|
||||
return getHost(container)
|
||||
},
|
||||
"getPort": func(container docker.Container) string {
|
||||
for key, value := range container.Config.Labels {
|
||||
if key == "traefik.port" {
|
||||
return value
|
||||
}
|
||||
}
|
||||
for key := range container.NetworkSettings.Ports {
|
||||
return key.Port()
|
||||
}
|
||||
return ""
|
||||
},
|
||||
"getWeight": func(container docker.Container) string {
|
||||
for key, value := range container.Config.Labels {
|
||||
if key == "traefik.weight" {
|
||||
return value
|
||||
}
|
||||
}
|
||||
return "0"
|
||||
},
|
||||
"replace": func(s1 string, s2 string, s3 string) string {
|
||||
return strings.Replace(s3, s1, s2, -1)
|
||||
},
|
||||
"getHost": getHost,
|
||||
}
|
||||
|
||||
func (provider *DockerProvider) Provide(configurationChan chan<- configMessage) error {
|
||||
if dockerClient, err := docker.NewClient(provider.Endpoint); err != nil {
|
||||
log.Errorf("Failed to create a client for docker, error: %s", err)
|
||||
@@ -105,10 +72,56 @@ func (provider *DockerProvider) Provide(configurationChan chan<- configMessage)
|
||||
}
|
||||
|
||||
func (provider *DockerProvider) loadDockerConfig(dockerClient *docker.Client) *Configuration {
|
||||
var DockerFuncMap = template.FuncMap{
|
||||
"getBackend": func(container docker.Container) string {
|
||||
if label, err := provider.getLabel(container, "traefik.backend"); err == nil {
|
||||
return label
|
||||
}
|
||||
return provider.getEscapedName(container.Name)
|
||||
},
|
||||
"getPort": func(container docker.Container) string {
|
||||
if label, err := provider.getLabel(container, "traefik.port"); err == nil {
|
||||
return label
|
||||
}
|
||||
for key := range container.NetworkSettings.Ports {
|
||||
return key.Port()
|
||||
}
|
||||
return ""
|
||||
},
|
||||
"getWeight": func(container docker.Container) string {
|
||||
if label, err := provider.getLabel(container, "traefik.weight"); err == nil {
|
||||
return label
|
||||
}
|
||||
return "0"
|
||||
},
|
||||
"getDomain": func(container docker.Container) string {
|
||||
if label, err := provider.getLabel(container, "traefik.domain"); err == nil {
|
||||
return label
|
||||
}
|
||||
return provider.Domain
|
||||
},
|
||||
"getProtocol": func(container docker.Container) string {
|
||||
if label, err := provider.getLabel(container, "traefik.protocol"); err == nil {
|
||||
return label
|
||||
}
|
||||
return "http"
|
||||
},
|
||||
"getPassHostHeader": func(container docker.Container) string {
|
||||
if passHostHeader, err := provider.getLabel(container, "traefik.frontend.passHostHeader"); err == nil {
|
||||
return passHostHeader
|
||||
}
|
||||
return "false"
|
||||
},
|
||||
"getFrontendValue": provider.GetFrontendValue,
|
||||
"getFrontendRule": provider.GetFrontendRule,
|
||||
"replace": func(s1 string, s2 string, s3 string) string {
|
||||
return strings.Replace(s3, s1, s2, -1)
|
||||
},
|
||||
}
|
||||
configuration := new(Configuration)
|
||||
containerList, _ := dockerClient.ListContainers(docker.ListContainersOptions{})
|
||||
containersInspected := []docker.Container{}
|
||||
hosts := map[string][]docker.Container{}
|
||||
frontends := map[string][]docker.Container{}
|
||||
|
||||
// get inspect containers
|
||||
for _, container := range containerList {
|
||||
@@ -131,20 +144,26 @@ func (provider *DockerProvider) loadDockerConfig(dockerClient *docker.Client) *C
|
||||
log.Debugf("Filtering disabled container %s", container.Name)
|
||||
return false
|
||||
}
|
||||
|
||||
if _, err := provider.getLabels(container, []string{"traefik.frontend.rule", "traefik.frontend.value"}); err != nil {
|
||||
log.Debugf("Filtering bad labeled container %s", container.Name)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}, containersInspected).([]docker.Container)
|
||||
|
||||
for _, container := range filteredContainers {
|
||||
hosts[getHost(container)] = append(hosts[getHost(container)], container)
|
||||
frontends[provider.getFrontendName(container)] = append(frontends[provider.getFrontendName(container)], container)
|
||||
}
|
||||
|
||||
templateObjects := struct {
|
||||
Containers []docker.Container
|
||||
Hosts map[string][]docker.Container
|
||||
Frontends map[string][]docker.Container
|
||||
Domain string
|
||||
}{
|
||||
filteredContainers,
|
||||
hosts,
|
||||
frontends,
|
||||
provider.Domain,
|
||||
}
|
||||
tmpl := template.New(provider.Filename).Funcs(DockerFuncMap)
|
||||
@@ -155,7 +174,7 @@ func (provider *DockerProvider) loadDockerConfig(dockerClient *docker.Client) *C
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
buf, err := Asset("providerTemplates/docker.tmpl")
|
||||
buf, err := Asset("templates/docker.tmpl")
|
||||
if err != nil {
|
||||
log.Error("Error reading file", err)
|
||||
}
|
||||
@@ -180,11 +199,47 @@ func (provider *DockerProvider) loadDockerConfig(dockerClient *docker.Client) *C
|
||||
return configuration
|
||||
}
|
||||
|
||||
func getHost(container docker.Container) string {
|
||||
func (provider *DockerProvider) getFrontendName(container docker.Container) string {
|
||||
// Replace '.' with '-' in quoted keys because of this issue https://github.com/BurntSushi/toml/issues/78
|
||||
frontendName := fmt.Sprintf("%s-%s", provider.GetFrontendRule(container), provider.GetFrontendValue(container))
|
||||
return strings.Replace(frontendName, ".", "-", -1)
|
||||
}
|
||||
|
||||
func (provider *DockerProvider) getEscapedName(name string) string {
|
||||
return strings.Replace(name, "/", "", -1)
|
||||
}
|
||||
|
||||
func (provider *DockerProvider) getLabel(container docker.Container, label string) (string, error) {
|
||||
for key, value := range container.Config.Labels {
|
||||
if key == "traefik.host" {
|
||||
return value
|
||||
if key == label {
|
||||
return value, nil
|
||||
}
|
||||
}
|
||||
return strings.Replace(strings.Replace(container.Name, "/", "", -1), ".", "-", -1)
|
||||
return "", errors.New("Label not found:" + label)
|
||||
}
|
||||
|
||||
func (provider *DockerProvider) getLabels(container docker.Container, labels []string) (map[string]string, error) {
|
||||
foundLabels := map[string]string{}
|
||||
for _, label := range labels {
|
||||
if foundLabel, err := provider.getLabel(container, label); err != nil {
|
||||
return nil, errors.New("Label not found: " + label)
|
||||
} else {
|
||||
foundLabels[label] = foundLabel
|
||||
}
|
||||
}
|
||||
return foundLabels, nil
|
||||
}
|
||||
|
||||
func (provider *DockerProvider) GetFrontendValue(container docker.Container) string {
|
||||
if label, err := provider.getLabel(container, "traefik.frontend.value"); err == nil {
|
||||
return label
|
||||
}
|
||||
return provider.getEscapedName(container.Name) + "." + provider.Domain
|
||||
}
|
||||
|
||||
func (provider *DockerProvider) GetFrontendRule(container docker.Container) string {
|
||||
if label, err := provider.getLabel(container, "traefik.frontend.rule"); err == nil {
|
||||
return label
|
||||
}
|
||||
return "Host"
|
||||
}
|
||||
|
BIN
docs/img/traefik-health.png
Normal file
BIN
docs/img/traefik-health.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
Binary file not shown.
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 53 KiB |
346
docs/index.md
346
docs/index.md
@@ -4,17 +4,17 @@ ___
|
||||
|
||||
# <a id="top"></a> Documentation
|
||||
|
||||
* [Basics](#basics)
|
||||
* [Global configuration](#global)
|
||||
* [File backend](#file)
|
||||
* [API backend](#api)
|
||||
* [Docker backend](#docker)
|
||||
* [Mesos/Marathon backend](#marathon)
|
||||
* [Consul backend](#consul)
|
||||
* [Etcd backend](#etcd)
|
||||
* [Zookeeper backend](#zk)
|
||||
* [Boltdb backend](#boltdb)
|
||||
* [Benchmarks](#benchmarks)
|
||||
- [Basics](#basics)
|
||||
- [Global configuration](#global)
|
||||
- [File backend](#file)
|
||||
- [API backend](#api)
|
||||
- [Docker backend](#docker)
|
||||
- [Mesos/Marathon backend](#marathon)
|
||||
- [Consul backend](#consul)
|
||||
- [Etcd backend](#etcd)
|
||||
- [Zookeeper backend](#zk)
|
||||
- [Boltdb backend](#boltdb)
|
||||
- [Benchmarks](#benchmarks)
|
||||
|
||||
|
||||
## <a id="basics"></a> Basics
|
||||
@@ -25,38 +25,39 @@ It supports several backends ([Docker :whale:](https://www.docker.com/), [Mesos/
|
||||
|
||||
Basically, Træfɪk is a http router, which sends traffic from frontends to http backends, following rules you have configured.
|
||||
|
||||
### Frontends
|
||||
### <a id="frontends"></a> Frontends
|
||||
|
||||
Frontends can be defined using the following rules:
|
||||
|
||||
* `Headers`: Headers adds a matcher for request header values. It accepts a sequence of key/value pairs to be matched. For example: `application/json`
|
||||
* `HeadersRegexp`: Regular expressions can be used with headers as well. It accepts a sequence of key/value pairs, where the value has regex support. For example: `application/(text|json)`
|
||||
* `Host`: Host adds a matcher for the URL host. It accepts a template with zero or more URL variables enclosed by `{}`. Variables can define an optional regexp pattern to be matched: `www.traefik.io`, `{subdomain:[a-z]+}.traefik.io`
|
||||
* `Methods`: Methods adds a matcher for HTTP methods. It accepts a sequence of one or more methods to be matched, e.g.: `GET`, `POST`, `PUT`
|
||||
* `Path`: Path adds a matcher for the URL path. It accepts a template with zero or more URL variables enclosed by `{}`. The template must start with a `/`. For exemple `/products/` `/articles/{category}/{id:[0-9]+}`
|
||||
* `PathPrefix`: PathPrefix adds a matcher for the URL path prefix. This matches if the given template is a prefix of the full URL path.
|
||||
- `Headers`: Headers adds a matcher for request header values. It accepts a sequence of key/value pairs to be matched. For example: `application/json`
|
||||
- `HeadersRegexp`: Regular expressions can be used with headers as well. It accepts a sequence of key/value pairs, where the value has regex support. For example: `application/(text|json)`
|
||||
- `Host`: Host adds a matcher for the URL host. It accepts a template with zero or more URL variables enclosed by `{}`. Variables can define an optional regexp pattern to be matched: `www.traefik.io`, `{subdomain:[a-z]+}.traefik.io`
|
||||
- `Methods`: Methods adds a matcher for HTTP methods. It accepts a sequence of one or more methods to be matched, e.g.: `GET`, `POST`, `PUT`
|
||||
- `Path`: Path adds a matcher for the URL path. It accepts a template with zero or more URL variables enclosed by `{}`. The template must start with a `/`. For exemple `/products/` `/articles/{category}/{id:[0-9]+}`
|
||||
- `PathPrefix`: PathPrefix adds a matcher for the URL path prefix. This matches if the given template is a prefix of the full URL path.
|
||||
|
||||
|
||||
A frontend is a set of rules that forwards the incoming http traffic to a backend.
|
||||
You can optionally enable `passHostHeader` to forward client `Host` header to the backend.
|
||||
|
||||
### HTTP Backends
|
||||
|
||||
A backend is responsible to load-balance the traffic coming from one or more frontends to a set of http servers.
|
||||
Various methods of load-balancing is supported:
|
||||
|
||||
* `wrr`: Weighted Round Robin
|
||||
* `drr`: Dynamic Round Robin: increases weights on servers that perform better than others. It also rolls back to original weights if the servers have changed.
|
||||
- `wrr`: Weighted Round Robin
|
||||
- `drr`: Dynamic Round Robin: increases weights on servers that perform better than others. It also rolls back to original weights if the servers have changed.
|
||||
|
||||
A circuit breaker can also be applied to a backend, preventing high loads on failing servers.
|
||||
It can be configured using:
|
||||
|
||||
* Methods: `LatencyAtQuantileMS`, `NetworkErrorRatio`, `ResponseCodeRatio`
|
||||
* Operators: `AND`, `OR`, `EQ`, `NEQ`, `LT`, `LE`, `GT`, `GE`
|
||||
- Methods: `LatencyAtQuantileMS`, `NetworkErrorRatio`, `ResponseCodeRatio`
|
||||
- Operators: `AND`, `OR`, `EQ`, `NEQ`, `LT`, `LE`, `GT`, `GE`
|
||||
|
||||
For example:
|
||||
* `NetworkErrorRatio() > 0.5`
|
||||
* `LatencyAtQuantileMS(50.0) > 50`
|
||||
* `ResponseCodeRatio(500, 600, 0, 600) > 0.5`
|
||||
- `NetworkErrorRatio() > 0.5`
|
||||
- `LatencyAtQuantileMS(50.0) > 50`
|
||||
- `ResponseCodeRatio(500, 600, 0, 600) > 0.5`
|
||||
|
||||
## <a id="global"></a> Global configuration
|
||||
|
||||
@@ -107,6 +108,16 @@ For example:
|
||||
#
|
||||
# CertFile = "traefik.crt"
|
||||
# KeyFile = "traefik.key"
|
||||
|
||||
# Backends throttle duration: minimum duration between 2 events from providers
|
||||
# before applying a new configuration. It avoids unnecessary reloads if multiples events
|
||||
# are sent in a short amount of time.
|
||||
#
|
||||
# Optional
|
||||
# Default: "2s"
|
||||
#
|
||||
# ProvidersThrottleDuration = "5s"
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -114,7 +125,7 @@ For example:
|
||||
|
||||
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.toml` :
|
||||
- simply add your configuration at the end of the global configuration file `traefik.toml` :
|
||||
|
||||
```toml
|
||||
# traefik.toml
|
||||
@@ -153,12 +164,13 @@ logLevel = "DEBUG"
|
||||
value = "test.localhost"
|
||||
[frontends.frontend2]
|
||||
backend = "backend1"
|
||||
passHostHeader = true
|
||||
[frontends.frontend2.routes.test_2]
|
||||
rule = "Path"
|
||||
value = "/test"
|
||||
```
|
||||
|
||||
* or put your rules in a separate file, for example `rules.tml`:
|
||||
- or put your rules in a separate file, for example `rules.tml`:
|
||||
|
||||
```toml
|
||||
# traefik.toml
|
||||
@@ -200,6 +212,7 @@ filename = "rules.toml"
|
||||
value = "test.localhost"
|
||||
[frontends.frontend2]
|
||||
backend = "backend1"
|
||||
passHostHeader = true
|
||||
[frontends.frontend2.routes.test_2]
|
||||
rule = "Path"
|
||||
value = "/test"
|
||||
@@ -230,89 +243,108 @@ address = ":8080"
|
||||
# KeyFile = "traefik.key"
|
||||
```
|
||||
|
||||
* `/`: provides a simple HTML frontend of Træfik
|
||||
- `/`: provides a simple HTML frontend of Træfik
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
* `/health`: `GET` json metrics
|
||||
- `/health`: `GET` json metrics
|
||||
|
||||
```sh
|
||||
$ curl -s "http://localhost:8080/health" | jq .
|
||||
{
|
||||
"average_response_time_sec": 0,
|
||||
"average_response_time": "0",
|
||||
"total_response_time_sec": 0,
|
||||
"total_response_time": "0",
|
||||
"total_count": 0,
|
||||
"pid": 12861,
|
||||
"uptime": "7m12.80607635s",
|
||||
"uptime_sec": 432.80607635,
|
||||
"time": "2015-09-22 10:25:16.448023473 +0200 CEST",
|
||||
"unixtime": 1442910316,
|
||||
"status_code_count": {},
|
||||
"total_status_code_count": {},
|
||||
"count": 0
|
||||
// Træfɪk PID
|
||||
"pid": 2458,
|
||||
// Træfɪk server uptime (formated time)
|
||||
"uptime": "39m6.885931127s",
|
||||
// Træfɪk server uptime in seconds
|
||||
"uptime_sec": 2346.885931127,
|
||||
// current server date
|
||||
"time": "2015-10-07 18:32:24.362238909 +0200 CEST",
|
||||
// current server date in seconds
|
||||
"unixtime": 1444235544,
|
||||
// count HTTP response status code in realtime
|
||||
"status_code_count": {
|
||||
"502": 1
|
||||
},
|
||||
// count HTTP response status code since Træfɪk started
|
||||
"total_status_code_count": {
|
||||
"200": 7,
|
||||
"404": 21,
|
||||
"502": 13
|
||||
},
|
||||
// count HTTP response
|
||||
"count": 1,
|
||||
// count HTTP response
|
||||
"total_count": 41,
|
||||
// sum of all response time (formated time)
|
||||
"total_response_time": "35.456865605s",
|
||||
// sum of all response time in seconds
|
||||
"total_response_time_sec": 35.456865605,
|
||||
// average response time (formated time)
|
||||
"average_response_time": "864.8016ms",
|
||||
// average response time in seconds
|
||||
"average_response_time_sec": 0.8648016000000001
|
||||
}
|
||||
```
|
||||
|
||||
* `/api`: `GET` configuration for all providers
|
||||
- `/api`: `GET` configuration for all providers
|
||||
|
||||
```sh
|
||||
$ curl -s "http://localhost:8080/api" | jq .
|
||||
{
|
||||
"file": {
|
||||
"Frontends": {
|
||||
"frontends": {
|
||||
"frontend2": {
|
||||
"Routes": {
|
||||
"routes": {
|
||||
"test_2": {
|
||||
"Value": "/test",
|
||||
"Rule": "Path"
|
||||
"value": "/test",
|
||||
"rule": "Path"
|
||||
}
|
||||
},
|
||||
"Backend": "backend1"
|
||||
"backend": "backend1"
|
||||
},
|
||||
"frontend1": {
|
||||
"Routes": {
|
||||
"routes": {
|
||||
"test_1": {
|
||||
"Value": "test.localhost",
|
||||
"Rule": "Host"
|
||||
"value": "test.localhost",
|
||||
"rule": "Host"
|
||||
}
|
||||
},
|
||||
"Backend": "backend2"
|
||||
"backend": "backend2"
|
||||
}
|
||||
},
|
||||
"Backends": {
|
||||
"backends": {
|
||||
"backend2": {
|
||||
"LoadBalancer": {
|
||||
"Method": "drr"
|
||||
"loadBalancer": {
|
||||
"method": "drr"
|
||||
},
|
||||
"CircuitBreaker": null,
|
||||
"Servers": {
|
||||
"servers": {
|
||||
"server2": {
|
||||
"Weight": 2,
|
||||
"weight": 2,
|
||||
"URL": "http://172.17.0.5:80"
|
||||
},
|
||||
"server1": {
|
||||
"Weight": 1,
|
||||
"URL": "http://172.17.0.4:80"
|
||||
"weight": 1,
|
||||
"url": "http://172.17.0.4:80"
|
||||
}
|
||||
}
|
||||
},
|
||||
"backend1": {
|
||||
"LoadBalancer": {
|
||||
"Method": "wrr"
|
||||
"loadBalancer": {
|
||||
"method": "wrr"
|
||||
},
|
||||
"CircuitBreaker": {
|
||||
"Expression": "NetworkErrorRatio() > 0.5"
|
||||
"circuitBreaker": {
|
||||
"expression": "NetworkErrorRatio() > 0.5"
|
||||
},
|
||||
"Servers": {
|
||||
"servers": {
|
||||
"server2": {
|
||||
"Weight": 1,
|
||||
"URL": "http://172.17.0.3:80"
|
||||
"weight": 1,
|
||||
"url": "http://172.17.0.3:80"
|
||||
},
|
||||
"server1": {
|
||||
"Weight": 10,
|
||||
"URL": "http://172.17.0.2:80"
|
||||
"weight": 10,
|
||||
"url": "http://172.17.0.2:80"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,14 +353,16 @@ $ curl -s "http://localhost:8080/api" | jq .
|
||||
}
|
||||
```
|
||||
|
||||
* `/api/providers`: `GET` providers
|
||||
* `/api/providers/{provider}`: `GET` or `PUT` provider
|
||||
* `/api/providers/{provider}/backends`: `GET` backends
|
||||
* `/api/providers/{provider}/backends/{backend}`: `GET` a backend
|
||||
* `/api/providers/{provider}/backends/{backend}/servers`: `GET` servers in a backend
|
||||
* `/api/providers/{provider}/backends/{backend}/servers/{server}`: `GET` a server in a backend
|
||||
* `/api/providers/{provider}/frontends`: `GET` frontends
|
||||
* `/api/providers/{provider}/frontends/{frontend}`: `GET` a frontend
|
||||
- `/api/providers`: `GET` providers
|
||||
- `/api/providers/{provider}`: `GET` or `PUT` provider
|
||||
- `/api/providers/{provider}/backends`: `GET` backends
|
||||
- `/api/providers/{provider}/backends/{backend}`: `GET` a backend
|
||||
- `/api/providers/{provider}/backends/{backend}/servers`: `GET` servers in a backend
|
||||
- `/api/providers/{provider}/backends/{backend}/servers/{server}`: `GET` a server in a backend
|
||||
- `/api/providers/{provider}/frontends`: `GET` frontends
|
||||
- `/api/providers/{provider}/frontends/{frontend}`: `GET` a frontend
|
||||
- `/api/providers/{provider}/frontends/{frontend}/routes`: `GET` routes in a frontend
|
||||
- `/api/providers/{provider}/frontends/{frontend}/routes/{route}`: `GET` a route in a frontend
|
||||
|
||||
|
||||
## <a id="docker"></a> Docker backend
|
||||
@@ -372,14 +406,18 @@ watch = true
|
||||
# filename = "docker.tmpl"
|
||||
```
|
||||
|
||||
|
||||
Labels can be used on containers to override default behaviour:
|
||||
|
||||
* `traefik.backend=foo`: assign the container to `foo` backend
|
||||
* `traefik.port=80`: register this port. Useful when the container exposes multiples ports.
|
||||
* `traefik.weight=10`: assign this weight to the container
|
||||
* `traefik.enable=false`: disable this container in Træfɪk
|
||||
* `traefik.host=bar`: override the default routing from {containerName}.{domain} to bar.{domain}
|
||||
- `traefik.backend=foo`: assign the container to `foo` backend
|
||||
- `traefik.port=80`: register this port. Useful when the container exposes multiples ports.
|
||||
- `traefik.protocol=https`: override the default `http` protocol
|
||||
- `traefik.weight=10`: assign this weight to the container
|
||||
- `traefik.enable=false`: disable this container in Træfɪk
|
||||
- `traefik.frontend.rule=Host`: override the default frontend rule (Default: Host). See [frontends](#frontends).
|
||||
- `traefik.frontend.value=test.example.com`: override the default frontend value (Default: `{containerName}.{domain}`) See [frontends](#frontends).
|
||||
- `traefik.frontend.passHostHeader=true`: forward client `Host` header to the backend.
|
||||
* `traefik.domain=traefik.localhost`: override the default domain
|
||||
|
||||
|
||||
## <a id="marathon"></a> Marathon backend
|
||||
|
||||
@@ -433,12 +471,15 @@ domain = "marathon.localhost"
|
||||
|
||||
Labels can be used on containers to override default behaviour:
|
||||
|
||||
* `traefik.backend=foo`: assign the application to `foo` backend
|
||||
* `traefik.port=80`: register this port. Useful when the application exposes multiples ports.
|
||||
* `traefik.weight=10`: assign this weight to the application
|
||||
* `traefik.enable=false`: disable this application in Træfɪk
|
||||
* `traefik.host=bar`: override the default routing from {appName}.{domain} to bar.{domain}
|
||||
* `traefik.prefixes=pf1,pf2`: use PathPrefix(es) instead of hostname for routing, use filename="providerTemplates/marathon-prefix.tmpl" with this option
|
||||
- `traefik.backend=foo`: assign the application to `foo` backend
|
||||
- `traefik.port=80`: register this port. Useful when the application exposes multiples ports.
|
||||
- `traefik.protocol=https`: override the default `http` protocol
|
||||
- `traefik.weight=10`: assign this weight to the application
|
||||
- `traefik.enable=false`: disable this application in Træfɪk
|
||||
- `traefik.frontend.rule=Host`: override the default frontend rule (Default: Host). See [frontends](#frontends).
|
||||
- `traefik.frontend.value=test.example.com`: override the default frontend value (Default: `{appName}.{domain}`) See [frontends](#frontends).
|
||||
- `traefik.frontend.passHostHeader=true`: forward client `Host` header to the backend.
|
||||
* `traefik.domain=traefik.localhost`: override the default domain
|
||||
|
||||
## <a id="consul"></a> Consul backend
|
||||
|
||||
@@ -480,6 +521,46 @@ prefix = "traefik"
|
||||
# filename = "consul.tmpl"
|
||||
```
|
||||
|
||||
The Keys-Values structure should look (using `prefix = "/traefik"`):
|
||||
|
||||
- backend 1
|
||||
|
||||
| Key | Value |
|
||||
|--------------------------------------------------------|-----------------------------|
|
||||
| `/traefik/backends/backend1/circuitbreaker/expression` | `NetworkErrorRatio() > 0.5` |
|
||||
| `/traefik/backends/backend1/servers/server1/url` | `http://172.17.0.2:80` |
|
||||
| `/traefik/backends/backend1/servers/server1/weight` | `10` |
|
||||
| `/traefik/backends/backend1/servers/server2/url` | `http://172.17.0.3:80` |
|
||||
| `/traefik/backends/backend1/servers/server2/weight` | `1` |
|
||||
|
||||
- backend 2
|
||||
|
||||
| Key | Value |
|
||||
|-----------------------------------------------------|------------------------|
|
||||
| `/traefik/backends/backend2/loadbalancer/method` | `drr` |
|
||||
| `/traefik/backends/backend2/servers/server1/url` | `http://172.17.0.4:80` |
|
||||
| `/traefik/backends/backend2/servers/server1/weight` | `1` |
|
||||
| `/traefik/backends/backend2/servers/server2/url` | `http://172.17.0.5:80` |
|
||||
| `/traefik/backends/backend2/servers/server2/weight` | `2` |
|
||||
|
||||
- frontend 1
|
||||
|
||||
| Key | Value |
|
||||
|----------------------------------------------------|------------------|
|
||||
| `/traefik/frontends/frontend1/backend` | `backend2` |
|
||||
| `/traefik/frontends/frontend1/routes/test_1/rule` | `Host` |
|
||||
| `/traefik/frontends/frontend1/routes/test_1/value` | `test.localhost` |
|
||||
|
||||
- frontend 2
|
||||
|
||||
| Key | Value |
|
||||
|----------------------------------------------------|------------|
|
||||
| `/traefik/frontends/frontend2/backend` | `backend1` |
|
||||
| `/traefik/frontends/frontend2/passHostHeader` | `true` |
|
||||
| `/traefik/frontends/frontend2/routes/test_2/rule` | `Path` |
|
||||
| `/traefik/frontends/frontend2/routes/test_2/value` | `/test` |
|
||||
|
||||
|
||||
## <a id="etcd"></a> Etcd backend
|
||||
|
||||
Træfɪk can be configured to use Etcd as a backend configuration:
|
||||
@@ -520,6 +601,46 @@ Træfɪk can be configured to use Etcd as a backend configuration:
|
||||
# filename = "etcd.tmpl"
|
||||
```
|
||||
|
||||
The Keys-Values structure should look (using `prefix = "/traefik"`):
|
||||
|
||||
- backend 1
|
||||
|
||||
| Key | Value |
|
||||
|--------------------------------------------------------|-----------------------------|
|
||||
| `/traefik/backends/backend1/circuitbreaker/expression` | `NetworkErrorRatio() > 0.5` |
|
||||
| `/traefik/backends/backend1/servers/server1/url` | `http://172.17.0.2:80` |
|
||||
| `/traefik/backends/backend1/servers/server1/weight` | `10` |
|
||||
| `/traefik/backends/backend1/servers/server2/url` | `http://172.17.0.3:80` |
|
||||
| `/traefik/backends/backend1/servers/server2/weight` | `1` |
|
||||
|
||||
- backend 2
|
||||
|
||||
| Key | Value |
|
||||
|-----------------------------------------------------|------------------------|
|
||||
| `/traefik/backends/backend2/loadbalancer/method` | `drr` |
|
||||
| `/traefik/backends/backend2/servers/server1/url` | `http://172.17.0.4:80` |
|
||||
| `/traefik/backends/backend2/servers/server1/weight` | `1` |
|
||||
| `/traefik/backends/backend2/servers/server2/url` | `http://172.17.0.5:80` |
|
||||
| `/traefik/backends/backend2/servers/server2/weight` | `2` |
|
||||
|
||||
- frontend 1
|
||||
|
||||
| Key | Value |
|
||||
|----------------------------------------------------|------------------|
|
||||
| `/traefik/frontends/frontend1/backend` | `backend2` |
|
||||
| `/traefik/frontends/frontend1/routes/test_1/rule` | `Host` |
|
||||
| `/traefik/frontends/frontend1/routes/test_1/value` | `test.localhost` |
|
||||
|
||||
- frontend 2
|
||||
|
||||
| Key | Value |
|
||||
|----------------------------------------------------|------------|
|
||||
| `/traefik/frontends/frontend2/backend` | `backend1` |
|
||||
| `/traefik/frontends/frontend2/passHostHeader` | `true` |
|
||||
| `/traefik/frontends/frontend2/routes/test_2/rule` | `Path` |
|
||||
| `/traefik/frontends/frontend2/routes/test_2/value` | `/test` |
|
||||
|
||||
|
||||
## <a id="zk"></a> Zookeeper backend
|
||||
|
||||
Træfɪk can be configured to use Zookeeper as a backend configuration:
|
||||
@@ -559,6 +680,45 @@ Træfɪk can be configured to use Zookeeper as a backend configuration:
|
||||
#
|
||||
# filename = "zookeeper.tmpl"
|
||||
```
|
||||
The Keys-Values structure should look (using `prefix = "/traefik"`):
|
||||
|
||||
- backend 1
|
||||
|
||||
| Key | Value |
|
||||
|--------------------------------------------------------|-----------------------------|
|
||||
| `/traefik/backends/backend1/circuitbreaker/expression` | `NetworkErrorRatio() > 0.5` |
|
||||
| `/traefik/backends/backend1/servers/server1/url` | `http://172.17.0.2:80` |
|
||||
| `/traefik/backends/backend1/servers/server1/weight` | `10` |
|
||||
| `/traefik/backends/backend1/servers/server2/url` | `http://172.17.0.3:80` |
|
||||
| `/traefik/backends/backend1/servers/server2/weight` | `1` |
|
||||
|
||||
- backend 2
|
||||
|
||||
| Key | Value |
|
||||
|-----------------------------------------------------|------------------------|
|
||||
| `/traefik/backends/backend2/loadbalancer/method` | `drr` |
|
||||
| `/traefik/backends/backend2/servers/server1/url` | `http://172.17.0.4:80` |
|
||||
| `/traefik/backends/backend2/servers/server1/weight` | `1` |
|
||||
| `/traefik/backends/backend2/servers/server2/url` | `http://172.17.0.5:80` |
|
||||
| `/traefik/backends/backend2/servers/server2/weight` | `2` |
|
||||
|
||||
- frontend 1
|
||||
|
||||
| Key | Value |
|
||||
|---------------------------------------------------|------------------|
|
||||
| `/traefik/frontends/frontend1/backend | `backend2` |
|
||||
| `/traefik/frontends/frontend1/routes/test_1/rule | `Host` |
|
||||
| `/traefik/frontends/frontend1/routes/test_1/value | `test.localhost` |
|
||||
|
||||
- frontend 2
|
||||
|
||||
| Key | Value |
|
||||
|----------------------------------------------------|------------|
|
||||
| `/traefik/frontends/frontend2/backend` | `backend1` |
|
||||
| `/traefik/frontends/frontend2/passHostHeader` | `true` |
|
||||
| `/traefik/frontends/frontend2/routes/test_2/rule` | `Path` |
|
||||
| `/traefik/frontends/frontend2/routes/test_2/value` | `/test` |
|
||||
|
||||
|
||||
## <a id="boltdb"></a> BoltDB backend
|
||||
|
||||
@@ -605,7 +765,7 @@ Træfɪk can be configured to use BoltDB as a backend configuration:
|
||||
|
||||
Here are some early Benchmarks between Nginx and Træfɪk acting as simple load balancers between two servers.
|
||||
|
||||
* Nginx:
|
||||
- Nginx:
|
||||
|
||||
```sh
|
||||
$ docker run -d -e VIRTUAL_HOST=test1.localhost emilevauge/whoami
|
||||
@@ -665,10 +825,9 @@ Percentage of the requests served within a certain time (ms)
|
||||
98% 12
|
||||
99% 13
|
||||
100% 36 (longest request)
|
||||
|
||||
```
|
||||
|
||||
* Træfɪk:
|
||||
- Træfɪk:
|
||||
|
||||
```sh
|
||||
$ docker run -d -l traefik.backend=test1 -l traefik.host=test1 emilevauge/whoami
|
||||
@@ -728,5 +887,4 @@ Percentage of the requests served within a certain time (ms)
|
||||
98% 11
|
||||
99% 13
|
||||
100% 22 (longest request)
|
||||
|
||||
```
|
||||
|
@@ -2,8 +2,10 @@
|
||||
Copyright
|
||||
*/
|
||||
|
||||
//go:generate go get github.com/jteeuwen/go-bindata/...
|
||||
//go:generate rm -vf gen.go
|
||||
//go:generate go-bindata -o gen.go static/... templates/... providerTemplates/...
|
||||
//go:generate go-bindata -o gen.go static/... templates/...
|
||||
|
||||
//go:generate mkdir -p vendor/github.com/docker/docker/autogen/dockerversion
|
||||
//go:generate cp script/dockerversion vendor/github.com/docker/docker/autogen/dockerversion/dockerversion.go
|
||||
|
||||
package main
|
||||
|
144
glide.yaml
Normal file
144
glide.yaml
Normal file
@@ -0,0 +1,144 @@
|
||||
package: main
|
||||
import:
|
||||
- package: github.com/coreos/go-etcd
|
||||
ref: cc90c7b091275e606ad0ca7102a23fb2072f3f5e
|
||||
subpackages:
|
||||
- etcd
|
||||
- package: github.com/docker/distribution
|
||||
ref: 9038e48c3b982f8e82281ea486f078a73731ac4e
|
||||
- package: github.com/mailgun/log
|
||||
ref: 44874009257d4d47ba9806f1b7f72a32a015e4d8
|
||||
- package: github.com/mailgun/oxy
|
||||
ref: 547c334d658398c05b346c0b79d8f47ba2e1473b
|
||||
subpackages:
|
||||
- cbreaker
|
||||
- forward
|
||||
- memmetrics
|
||||
- roundrobin
|
||||
- utils
|
||||
- package: github.com/hashicorp/consul
|
||||
ref: de080672fee9e6104572eeea89eccdca135bb918
|
||||
subpackages:
|
||||
- api
|
||||
- package: github.com/samuel/go-zookeeper
|
||||
ref: fa6674abf3f4580b946a01bf7a1ce4ba8766205b
|
||||
subpackages:
|
||||
- zk
|
||||
- package: github.com/docker/libtrust
|
||||
ref: 9cbd2a1374f46905c68a4eb3694a130610adc62a
|
||||
- package: gopkg.in/check.v1
|
||||
ref: 11d3bc7aa68e238947792f30573146a3231fc0f1
|
||||
- package: golang.org/x/net
|
||||
ref: d9558e5c97f85372afee28cf2b6059d7d3818919
|
||||
subpackages:
|
||||
- context
|
||||
- package: github.com/gorilla/handlers
|
||||
ref: 40694b40f4a928c062f56849989d3e9cd0570e5f
|
||||
- package: github.com/docker/libkv
|
||||
ref: 3732f7ff1b56057c3158f10bceb1e79133025373
|
||||
- package: github.com/alecthomas/template
|
||||
ref: b867cc6ab45cece8143cfcc6fc9c77cf3f2c23c0
|
||||
- package: github.com/vdemeester/shakers
|
||||
ref: 8fe734f75f3a70b651cbfbf8a55a009da09e8dc5
|
||||
- package: github.com/alecthomas/units
|
||||
ref: 6b4e7dc5e3143b85ea77909c72caf89416fc2915
|
||||
- package: github.com/gambol99/go-marathon
|
||||
ref: 0ba31bcb0d7633ba1888d744c42990eb15281cf1
|
||||
- package: github.com/mailgun/predicate
|
||||
ref: cb0bff91a7ab7cf7571e661ff883fc997bc554a3
|
||||
- package: github.com/thoas/stats
|
||||
ref: 54ed61c2b47e263ae2f01b86837b0c4bd1da28e8
|
||||
- package: github.com/samalba/dockerclient
|
||||
ref: cfb489c624b635251a93e74e1e90eb0959c5367f
|
||||
- package: github.com/Sirupsen/logrus
|
||||
ref: 418b41d23a1bf978c06faea5313ba194650ac088
|
||||
- package: github.com/unrolled/render
|
||||
ref: 26b4e3aac686940fe29521545afad9966ddfc80c
|
||||
- package: github.com/flynn/go-shlex
|
||||
ref: 3f9db97f856818214da2e1057f8ad84803971cff
|
||||
- package: github.com/fsouza/go-dockerclient
|
||||
ref: 0239034d42f665efa17fd77c39f891c2f9f32922
|
||||
- package: github.com/boltdb/bolt
|
||||
ref: 51f99c862475898df9773747d3accd05a7ca33c1
|
||||
- package: gopkg.in/mgo.v2
|
||||
ref: 22287bab4379e1fbf6002fb4eb769888f3fb224c
|
||||
subpackages:
|
||||
- bson
|
||||
- package: github.com/docker/docker
|
||||
ref: f39987afe8d611407887b3094c03d6ba6a766a67
|
||||
subpackages:
|
||||
- autogen
|
||||
- api
|
||||
- cliconfig
|
||||
- daemon/network
|
||||
- graph/tags
|
||||
- image
|
||||
- opts
|
||||
- pkg/archive
|
||||
- pkg/fileutils
|
||||
- pkg/homedir
|
||||
- pkg/httputils
|
||||
- pkg/ioutils
|
||||
- pkg/jsonmessage
|
||||
- pkg/mflag
|
||||
- pkg/nat
|
||||
- pkg/parsers
|
||||
- pkg/pools
|
||||
- pkg/promise
|
||||
- pkg/random
|
||||
- pkg/stdcopy
|
||||
- pkg/stringid
|
||||
- pkg/symlink
|
||||
- pkg/system
|
||||
- pkg/tarsum
|
||||
- pkg/term
|
||||
- pkg/timeutils
|
||||
- pkg/tlsconfig
|
||||
- pkg/ulimit
|
||||
- pkg/units
|
||||
- pkg/urlutil
|
||||
- pkg/useragent
|
||||
- pkg/version
|
||||
- registry
|
||||
- runconfig
|
||||
- utils
|
||||
- volume
|
||||
- package: github.com/mailgun/timetools
|
||||
ref: fd192d755b00c968d312d23f521eb0cdc6f66bd0
|
||||
- package: github.com/codegangsta/negroni
|
||||
ref: c7477ad8e330bef55bf1ebe300cf8aa67c492d1b
|
||||
- package: gopkg.in/yaml.v2
|
||||
ref: 7ad95dd0798a40da1ccdff6dff35fd177b5edf40
|
||||
- package: github.com/opencontainers/runc
|
||||
ref: 4ab132458fc3e9dbeea624153e0331952dc4c8d5
|
||||
subpackages:
|
||||
- libcontainer/user
|
||||
- package: github.com/gorilla/mux
|
||||
ref: f15e0c49460fd49eebe2bcc8486b05d1bef68d3a
|
||||
- package: github.com/BurntSushi/ty
|
||||
ref: 6add9cd6ad42d389d6ead1dde60b4ad71e46fd74
|
||||
- package: github.com/elazarl/go-bindata-assetfs
|
||||
ref: d5cac425555ca5cf00694df246e04f05e6a55150
|
||||
- package: github.com/BurntSushi/toml
|
||||
ref: bd2bdf7f18f849530ef7a1c29a4290217cab32a1
|
||||
- package: gopkg.in/alecthomas/kingpin.v2
|
||||
ref: 639879d6110b1b0409410c7b737ef0bb18325038
|
||||
- package: github.com/docker/libcompose
|
||||
ref: 79ef5d150f053a5b12f16b02d8844ed7cf33611a
|
||||
subpackages:
|
||||
- docker
|
||||
- logger
|
||||
- lookup
|
||||
- project
|
||||
- utils
|
||||
- package: github.com/cenkalti/backoff
|
||||
ref: 4dc77674aceaabba2c7e3da25d4c823edfb73f99
|
||||
- package: gopkg.in/fsnotify.v1
|
||||
ref: 96c060f6a6b7e0d6f75fddd10efeaca3e5d1bcb0
|
||||
- package: github.com/mailgun/manners
|
||||
ref: 37136f736785d7c6aa3b9a27b4b2dd1028ca6d79
|
||||
- package: github.com/gorilla/context
|
||||
ref: 215affda49addc4c8ef7e2534915df2c8c35c6cd
|
||||
- package: github.com/codahale/hdrhistogram
|
||||
ref: 954f16e8b9ef0e5d5189456aa4c1202758e04f17
|
||||
- package: github.com/gorilla/websocket
|
@@ -38,7 +38,7 @@ func (s *SimpleSuite) TestSimpleDefaultConfig(c *check.C) {
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
// TODO validate : run on 80
|
||||
resp, err := http.Get("http://127.0.0.1/")
|
||||
|
||||
|
@@ -14,7 +14,7 @@ func (s *ConsulSuite) TestSimpleConfiguration(c *check.C) {
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
// TODO validate : run on 80
|
||||
resp, err := http.Get("http://127.0.0.1/")
|
||||
|
||||
|
@@ -18,7 +18,7 @@ func (s *DockerSuite) TestSimpleConfiguration(c *check.C) {
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
// TODO validate : run on 80
|
||||
resp, err := http.Get("http://127.0.0.1/")
|
||||
|
||||
|
@@ -14,8 +14,24 @@ func (s *FileSuite) TestSimpleConfiguration(c *check.C) {
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
// TODO validate : run on 80
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
resp, err := http.Get("http://127.0.0.1/")
|
||||
|
||||
// Expected a 404 as we did not configure anything
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
||||
|
||||
killErr := cmd.Process.Kill()
|
||||
c.Assert(killErr, checker.IsNil)
|
||||
}
|
||||
|
||||
// #56 regression test, make sure it does not fail
|
||||
func (s *FileSuite) TestSimpleConfigurationNoPanic(c *check.C) {
|
||||
cmd := exec.Command(traefikBinary, "fixtures/file/56-simple-panic.toml")
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
resp, err := http.Get("http://127.0.0.1/")
|
||||
|
||||
// Expected a 404 as we did not configure anything
|
||||
|
11
integration/fixtures/file/56-simple-panic.toml
Normal file
11
integration/fixtures/file/56-simple-panic.toml
Normal file
@@ -0,0 +1,11 @@
|
||||
# Reverse proxy port
|
||||
#
|
||||
# Optional
|
||||
# Default: ":80"
|
||||
#
|
||||
# port = ":80"
|
||||
#
|
||||
# LogLevel
|
||||
logLevel = "DEBUG"
|
||||
|
||||
[file]
|
@@ -9,3 +9,36 @@
|
||||
logLevel = "DEBUG"
|
||||
|
||||
[file]
|
||||
|
||||
# rules
|
||||
[backends]
|
||||
[backends.backend1]
|
||||
[backends.backend1.circuitbreaker]
|
||||
expression = "NetworkErrorRatio() > 0.5"
|
||||
[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.LoadBalancer]
|
||||
method = "drr"
|
||||
[backends.backend2.servers.server1]
|
||||
url = "http://172.17.0.4:80"
|
||||
weight = 1
|
||||
[backends.backend2.servers.server2]
|
||||
url = "http://172.17.0.5:80"
|
||||
weight = 2
|
||||
|
||||
[frontends]
|
||||
[frontends.frontend1]
|
||||
backend = "backend2"
|
||||
[frontends.frontend1.routes.test_1]
|
||||
rule = "Host"
|
||||
value = "test.localhost"
|
||||
[frontends.frontend2]
|
||||
backend = "backend1"
|
||||
[frontends.frontend2.routes.test_2]
|
||||
rule = "Path"
|
||||
value = "/test"
|
||||
|
@@ -9,7 +9,6 @@ import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"github.com/docker/libcompose/docker"
|
||||
"github.com/docker/libcompose/project"
|
||||
@@ -72,7 +71,7 @@ func (s *MarathonSuite) SetUpSuite(c *check.C) {
|
||||
|
||||
type BaseSuite struct {
|
||||
composeProject *project.Project
|
||||
listenChan chan project.ProjectEvent
|
||||
listenChan chan project.Event
|
||||
started chan bool
|
||||
stopped chan bool
|
||||
deleted chan bool
|
||||
@@ -82,14 +81,12 @@ func (s *BaseSuite) TearDownSuite(c *check.C) {
|
||||
// shutdown and delete compose project
|
||||
if s.composeProject != nil {
|
||||
s.composeProject.Down()
|
||||
// Waiting for libcompose#55 to be merged
|
||||
// <-s.stopped
|
||||
time.Sleep(2 * time.Second)
|
||||
<-s.stopped
|
||||
defer close(s.stopped)
|
||||
|
||||
s.composeProject.Delete()
|
||||
// Waiting for libcompose#55 to be merged
|
||||
// <-s.deleted
|
||||
time.Sleep(2 * time.Second)
|
||||
<-s.deleted
|
||||
defer close(s.deleted)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,32 +100,32 @@ func (s *BaseSuite) createComposeProject(c *check.C, name string) {
|
||||
c.Assert(err, checker.IsNil)
|
||||
s.composeProject = composeProject
|
||||
|
||||
s.listenChan = make(chan project.ProjectEvent)
|
||||
s.started = make(chan bool)
|
||||
s.stopped = make(chan bool)
|
||||
s.deleted = make(chan bool)
|
||||
|
||||
s.listenChan = make(chan project.Event)
|
||||
go s.startListening(c)
|
||||
|
||||
composeProject.AddListener(s.listenChan)
|
||||
|
||||
composeProject.Start()
|
||||
|
||||
// FIXME Wait for compose to start
|
||||
// Waiting for libcompose#55 to be merged
|
||||
// <-s.started
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
// Wait for compose to start
|
||||
<-s.started
|
||||
defer close(s.started)
|
||||
}
|
||||
|
||||
func (s *BaseSuite) startListening(c *check.C) {
|
||||
for event := range s.listenChan {
|
||||
// FIXME Remove this when it's working (libcompose#55)
|
||||
// fmt.Fprintf(os.Stdout, "Event: %s (%v)\n", event.Event, event)
|
||||
// FIXME Add a timeout on event
|
||||
if event.Event == project.PROJECT_UP_DONE {
|
||||
// FIXME Add a timeout on event ?
|
||||
if event.EventType == project.EventProjectStartDone {
|
||||
s.started <- true
|
||||
}
|
||||
if event.Event == project.PROJECT_DOWN_DONE {
|
||||
if event.EventType == project.EventProjectDownDone {
|
||||
s.stopped <- true
|
||||
}
|
||||
if event.Event == project.PROJECT_DELETE_DONE {
|
||||
if event.EventType == project.EventProjectDeleteDone {
|
||||
s.deleted <- true
|
||||
}
|
||||
}
|
||||
|
@@ -10,15 +10,15 @@ import (
|
||||
)
|
||||
|
||||
func (s *MarathonSuite) TestSimpleConfiguration(c *check.C) {
|
||||
cmd := exec.Command(traefikBinary, "fixtures/consul/simple.toml")
|
||||
cmd := exec.Command(traefikBinary, "fixtures/marathon/simple.toml")
|
||||
err := cmd.Start()
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
// TODO validate : run on 80
|
||||
resp, err := http.Get("http://127.0.0.1/")
|
||||
|
||||
// Expected a 404 as we did not comfigure anything
|
||||
// Expected a 404 as we did not configure anything
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(resp.StatusCode, checker.Equals, 404)
|
||||
|
||||
|
3
kv.go
3
kv.go
@@ -88,6 +88,7 @@ func (provider *KvProvider) provide(configurationChan chan<- configMessage) erro
|
||||
[]string{provider.Endpoint},
|
||||
&store.Config{
|
||||
ConnectionTimeout: 30 * time.Second,
|
||||
Bucket: "traefik",
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
@@ -166,7 +167,7 @@ func (provider *KvProvider) loadConfig() *Configuration {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
buf, err := Asset("providerTemplates/kv.tmpl")
|
||||
buf, err := Asset("templates/kv.tmpl")
|
||||
if err != nil {
|
||||
log.Error("Error reading file", err)
|
||||
}
|
||||
|
144
marathon.go
144
marathon.go
@@ -6,6 +6,7 @@ import (
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"errors"
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/BurntSushi/ty/fun"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
@@ -21,42 +22,6 @@ type MarathonProvider struct {
|
||||
NetworkInterface string
|
||||
}
|
||||
|
||||
var MarathonFuncMap = template.FuncMap{
|
||||
"getPort": func(task marathon.Task) string {
|
||||
for _, port := range task.Ports {
|
||||
return strconv.Itoa(port)
|
||||
}
|
||||
return ""
|
||||
},
|
||||
"getHost": func(application marathon.Application) string {
|
||||
for key, value := range application.Labels {
|
||||
if key == "traefik.host" {
|
||||
return value
|
||||
}
|
||||
}
|
||||
return strings.Replace(application.ID, "/", "", 1)
|
||||
},
|
||||
"getWeight": func(application marathon.Application) string {
|
||||
for key, value := range application.Labels {
|
||||
if key == "traefik.weight" {
|
||||
return value
|
||||
}
|
||||
}
|
||||
return "0"
|
||||
},
|
||||
"getPrefixes": func(application marathon.Application) ([]string, error) {
|
||||
for key, value := range application.Labels {
|
||||
if key == "traefik.prefixes" {
|
||||
return strings.Split(value, ","), nil
|
||||
}
|
||||
}
|
||||
return []string{}, nil
|
||||
},
|
||||
"replace": func(s1 string, s2 string, s3 string) string {
|
||||
return strings.Replace(s3, s1, s2, -1)
|
||||
},
|
||||
}
|
||||
|
||||
func (provider *MarathonProvider) Provide(configurationChan chan<- configMessage) error {
|
||||
config := marathon.NewDefaultConfig()
|
||||
config.URL = provider.Endpoint
|
||||
@@ -91,6 +56,53 @@ func (provider *MarathonProvider) Provide(configurationChan chan<- configMessage
|
||||
}
|
||||
|
||||
func (provider *MarathonProvider) loadMarathonConfig() *Configuration {
|
||||
var MarathonFuncMap = template.FuncMap{
|
||||
"getPort": func(task marathon.Task) string {
|
||||
for _, port := range task.Ports {
|
||||
return strconv.Itoa(port)
|
||||
}
|
||||
return ""
|
||||
},
|
||||
"getWeight": func(task marathon.Task, applications []marathon.Application) string {
|
||||
application, errApp := getApplication(task, applications)
|
||||
if errApp != nil {
|
||||
log.Errorf("Unable to get marathon application from task %s", task.AppID)
|
||||
return "0"
|
||||
}
|
||||
if label, err := provider.getLabel(application, "traefik.weight"); err == nil {
|
||||
return label
|
||||
}
|
||||
return "0"
|
||||
},
|
||||
"getDomain": func(application marathon.Application) string {
|
||||
if label, err := provider.getLabel(application, "traefik.domain"); err == nil {
|
||||
return label
|
||||
}
|
||||
return provider.Domain
|
||||
},
|
||||
"replace": func(s1 string, s2 string, s3 string) string {
|
||||
return strings.Replace(s3, s1, s2, -1)
|
||||
},
|
||||
"getProtocol": func(task marathon.Task, applications []marathon.Application) string {
|
||||
application, errApp := getApplication(task, applications)
|
||||
if errApp != nil {
|
||||
log.Errorf("Unable to get marathon application from task %s", task.AppID)
|
||||
return "http"
|
||||
}
|
||||
if label, err := provider.getLabel(application, "traefik.protocol"); err == nil {
|
||||
return label
|
||||
}
|
||||
return "http"
|
||||
},
|
||||
"getPassHostHeader": func(application marathon.Application) string {
|
||||
if passHostHeader, err := provider.getLabel(application, "traefik.frontend.passHostHeader"); err == nil {
|
||||
return passHostHeader
|
||||
}
|
||||
return "false"
|
||||
},
|
||||
"getFrontendValue": provider.GetFrontendValue,
|
||||
"getFrontendRule": provider.GetFrontendRule,
|
||||
}
|
||||
configuration := new(Configuration)
|
||||
|
||||
applications, err := provider.marathonClient.Applications(nil)
|
||||
@@ -108,23 +120,38 @@ func (provider *MarathonProvider) loadMarathonConfig() *Configuration {
|
||||
//filter tasks
|
||||
filteredTasks := fun.Filter(func(task marathon.Task) bool {
|
||||
if len(task.Ports) == 0 {
|
||||
log.Debug("Filtering marathon task without port", task.AppID)
|
||||
log.Debug("Filtering marathon task without port %s", task.AppID)
|
||||
return false
|
||||
}
|
||||
application := getApplication(task, applications.Apps)
|
||||
if application == nil {
|
||||
application, errApp := getApplication(task, applications.Apps)
|
||||
if errApp != nil {
|
||||
log.Errorf("Unable to get marathon application from task %s", task.AppID)
|
||||
return false
|
||||
}
|
||||
_, err := strconv.Atoi(application.Labels["traefik.port"])
|
||||
if len(application.Ports) > 1 && err != nil {
|
||||
log.Debug("Filtering marathon task with more than 1 port and no traefik.port label", task.AppID)
|
||||
log.Debugf("Filtering marathon task %s with more than 1 port and no traefik.port label", task.AppID)
|
||||
return false
|
||||
}
|
||||
if application.Labels["traefik.enable"] == "false" {
|
||||
log.Debug("Filtering disabled marathon task", task.AppID)
|
||||
log.Debugf("Filtering disabled marathon task %s", task.AppID)
|
||||
return false
|
||||
}
|
||||
//filter healthchecks
|
||||
if application.HasHealthChecks() {
|
||||
if task.HasHealthCheckResults() {
|
||||
for _, healthcheck := range task.HealthCheckResult {
|
||||
// found one bad healthcheck, return false
|
||||
if !healthcheck.Alive {
|
||||
log.Debugf("Filtering marathon task %s with bad healthcheck", task.AppID)
|
||||
return false
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Debugf("Filtering marathon task %s with bad healthcheck", task.AppID)
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}, tasks.Tasks).([]marathon.Task)
|
||||
|
||||
@@ -160,7 +187,7 @@ func (provider *MarathonProvider) loadMarathonConfig() *Configuration {
|
||||
return nil
|
||||
}
|
||||
} else {
|
||||
buf, err := Asset("providerTemplates/marathon.tmpl")
|
||||
buf, err := Asset("templates/marathon.tmpl")
|
||||
if err != nil {
|
||||
log.Error("Error reading file", err)
|
||||
}
|
||||
@@ -187,11 +214,38 @@ func (provider *MarathonProvider) loadMarathonConfig() *Configuration {
|
||||
return configuration
|
||||
}
|
||||
|
||||
func getApplication(task marathon.Task, apps []marathon.Application) *marathon.Application {
|
||||
func getApplication(task marathon.Task, apps []marathon.Application) (marathon.Application, error) {
|
||||
for _, application := range apps {
|
||||
if application.ID == task.AppID {
|
||||
return &application
|
||||
return application, nil
|
||||
}
|
||||
}
|
||||
return nil
|
||||
return marathon.Application{}, errors.New("Application not found: " + task.AppID)
|
||||
}
|
||||
|
||||
func (provider *MarathonProvider) getLabel(application marathon.Application, label string) (string, error) {
|
||||
for key, value := range application.Labels {
|
||||
if key == label {
|
||||
return value, nil
|
||||
}
|
||||
}
|
||||
return "", errors.New("Label not found:" + label)
|
||||
}
|
||||
|
||||
func (provider *MarathonProvider) getEscapedName(name string) string {
|
||||
return strings.Replace(name, "/", "", -1)
|
||||
}
|
||||
|
||||
func (provider *MarathonProvider) GetFrontendValue(application marathon.Application) string {
|
||||
if label, err := provider.getLabel(application, "traefik.frontend.value"); err == nil {
|
||||
return label
|
||||
}
|
||||
return provider.getEscapedName(application.ID) + "." + provider.Domain
|
||||
}
|
||||
|
||||
func (provider *MarathonProvider) GetFrontendRule(application marathon.Application) string {
|
||||
if label, err := provider.getLabel(application, "traefik.frontend.rule"); err == nil {
|
||||
return label
|
||||
}
|
||||
return "Host"
|
||||
}
|
||||
|
52
middlewares/websocket.go
Normal file
52
middlewares/websocket.go
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
Copyright
|
||||
*/
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/mailgun/oxy/roundrobin"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type WebsocketUpgrader struct {
|
||||
rr *roundrobin.RoundRobin
|
||||
}
|
||||
|
||||
func NewWebsocketUpgrader(rr *roundrobin.RoundRobin) *WebsocketUpgrader {
|
||||
wu := WebsocketUpgrader{
|
||||
rr: rr,
|
||||
}
|
||||
return &wu
|
||||
}
|
||||
|
||||
func (u *WebsocketUpgrader) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
// If request is websocket, serve with golang websocket server to do protocol handshake
|
||||
if strings.Join(req.Header["Upgrade"], "") == "websocket" {
|
||||
start := time.Now().UTC()
|
||||
url, err := u.rr.NextServer()
|
||||
if err != nil {
|
||||
log.Errorf("Can't round robin in websocket middleware")
|
||||
return
|
||||
}
|
||||
log.Debugf("Websocket forward to %s", url.String())
|
||||
NewProxy(url).ServeHTTP(w, req)
|
||||
|
||||
if req.TLS != nil {
|
||||
log.Debugf("Round trip: %v, duration: %v tls:version: %x, tls:resume:%t, tls:csuite:%x, tls:server:%v",
|
||||
req.URL, time.Now().UTC().Sub(start),
|
||||
req.TLS.Version,
|
||||
req.TLS.DidResume,
|
||||
req.TLS.CipherSuite,
|
||||
req.TLS.ServerName)
|
||||
} else {
|
||||
log.Debugf("Round trip: %v, duration: %v",
|
||||
req.URL, time.Now().UTC().Sub(start))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
u.rr.ServeHTTP(w, req)
|
||||
}
|
179
middlewares/websocketproxy.go
Normal file
179
middlewares/websocketproxy.go
Normal file
@@ -0,0 +1,179 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
// Original developpement made by https://github.com/koding/websocketproxy
|
||||
var (
|
||||
// DefaultUpgrader specifies the parameters for upgrading an HTTP
|
||||
// connection to a WebSocket connection.
|
||||
DefaultUpgrader = &websocket.Upgrader{
|
||||
ReadBufferSize: 1024,
|
||||
WriteBufferSize: 1024,
|
||||
}
|
||||
|
||||
// DefaultDialer is a dialer with all fields set to the default zero values.
|
||||
DefaultDialer = websocket.DefaultDialer
|
||||
)
|
||||
|
||||
// WebsocketProxy is an HTTP Handler that takes an incoming WebSocket
|
||||
// connection and proxies it to another server.
|
||||
type WebsocketProxy struct {
|
||||
// Backend returns the backend URL which the proxy uses to reverse proxy
|
||||
// the incoming WebSocket connection. Request is the initial incoming and
|
||||
// unmodified request.
|
||||
Backend func(*http.Request) *url.URL
|
||||
|
||||
// Upgrader specifies the parameters for upgrading a incoming HTTP
|
||||
// connection to a WebSocket connection. If nil, DefaultUpgrader is used.
|
||||
Upgrader *websocket.Upgrader
|
||||
|
||||
// Dialer contains options for connecting to the backend WebSocket server.
|
||||
// If nil, DefaultDialer is used.
|
||||
Dialer *websocket.Dialer
|
||||
}
|
||||
|
||||
// ProxyHandler returns a new http.Handler interface that reverse proxies the
|
||||
// request to the given target.
|
||||
func ProxyHandler(target *url.URL) http.Handler {
|
||||
return http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
||||
NewProxy(target).ServeHTTP(rw, req)
|
||||
})
|
||||
}
|
||||
|
||||
// NewProxy returns a new Websocket reverse proxy that rewrites the
|
||||
// URL's to the scheme, host and base path provider in target.
|
||||
func NewProxy(target *url.URL) *WebsocketProxy {
|
||||
backend := func(r *http.Request) *url.URL {
|
||||
// Shallow copy
|
||||
u := *target
|
||||
u.Fragment = r.URL.Fragment
|
||||
u.Path = r.URL.Path
|
||||
u.RawQuery = r.URL.RawQuery
|
||||
rurl := u.String()
|
||||
if strings.HasPrefix(rurl, "http") {
|
||||
u.Scheme = "ws"
|
||||
}
|
||||
if strings.HasPrefix(rurl, "https") {
|
||||
u.Scheme = "wss"
|
||||
}
|
||||
return &u
|
||||
}
|
||||
return &WebsocketProxy{Backend: backend}
|
||||
}
|
||||
|
||||
// ServeHTTP implements the http.Handler that proxies WebSocket connections.
|
||||
func (w *WebsocketProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||
if w.Backend == nil {
|
||||
log.Errorf("Websocketproxy: backend function is not defined")
|
||||
http.Error(rw, "Backend not found", http.StatusInternalServerError)
|
||||
http.NotFound(rw, req)
|
||||
return
|
||||
}
|
||||
|
||||
backendURL := w.Backend(req)
|
||||
if backendURL == nil {
|
||||
log.Errorf("Websocketproxy: backend URL is nil")
|
||||
http.Error(rw, "Backend URL is nil", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
dialer := w.Dialer
|
||||
if w.Dialer == nil {
|
||||
dialer = DefaultDialer
|
||||
}
|
||||
|
||||
// Pass headers from the incoming request to the dialer to forward them to
|
||||
// the final destinations.
|
||||
requestHeader := http.Header{}
|
||||
requestHeader.Add("Origin", req.Header.Get("Origin"))
|
||||
for _, prot := range req.Header[http.CanonicalHeaderKey("Sec-WebSocket-Protocol")] {
|
||||
requestHeader.Add("Sec-WebSocket-Protocol", prot)
|
||||
}
|
||||
for _, cookie := range req.Header[http.CanonicalHeaderKey("Cookie")] {
|
||||
requestHeader.Add("Cookie", cookie)
|
||||
}
|
||||
for _, auth := range req.Header[http.CanonicalHeaderKey("Authorization")] {
|
||||
requestHeader.Add("Authorization", auth)
|
||||
}
|
||||
|
||||
// Pass X-Forwarded-For headers too, code below is a part of
|
||||
// httputil.ReverseProxy. See http://en.wikipedia.org/wiki/X-Forwarded-For
|
||||
// for more information
|
||||
// TODO: use RFC7239 http://tools.ietf.org/html/rfc7239
|
||||
if clientIP, _, err := net.SplitHostPort(req.RemoteAddr); err == nil {
|
||||
// If we aren't the first proxy retain prior
|
||||
// X-Forwarded-For information as a comma+space
|
||||
// separated list and fold multiple headers into one.
|
||||
if prior, ok := req.Header["X-Forwarded-For"]; ok {
|
||||
clientIP = strings.Join(prior, ", ") + ", " + clientIP
|
||||
}
|
||||
requestHeader.Set("X-Forwarded-For", clientIP)
|
||||
}
|
||||
|
||||
// Set the originating protocol of the incoming HTTP request. The SSL might
|
||||
// be terminated on our site and because we doing proxy adding this would
|
||||
// be helpful for applications on the backend.
|
||||
requestHeader.Set("X-Forwarded-Proto", "http")
|
||||
if req.TLS != nil {
|
||||
requestHeader.Set("X-Forwarded-Proto", "https")
|
||||
}
|
||||
|
||||
//frontend Origin != backend Origin
|
||||
requestHeader.Del("Origin")
|
||||
|
||||
// Connect to the backend URL, also pass the headers we get from the requst
|
||||
// together with the Forwarded headers we prepared above.
|
||||
// TODO: support multiplexing on the same backend connection instead of
|
||||
// opening a new TCP connection time for each request. This should be
|
||||
// optional:
|
||||
// http://tools.ietf.org/html/draft-ietf-hybi-websocket-multiplexing-01
|
||||
connBackend, resp, err := dialer.Dial(backendURL.String(), requestHeader)
|
||||
if err != nil {
|
||||
log.Errorf("Websocketproxy: couldn't dial to remote backend url %s, %s, %+v", backendURL.String(), err, resp)
|
||||
http.Error(rw, "Remote backend unreachable", http.StatusBadGateway)
|
||||
return
|
||||
}
|
||||
defer connBackend.Close()
|
||||
|
||||
upgrader := w.Upgrader
|
||||
if w.Upgrader == nil {
|
||||
upgrader = DefaultUpgrader
|
||||
}
|
||||
|
||||
// Only pass those headers to the upgrader.
|
||||
upgradeHeader := http.Header{}
|
||||
upgradeHeader.Set("Sec-WebSocket-Protocol",
|
||||
resp.Header.Get(http.CanonicalHeaderKey("Sec-WebSocket-Protocol")))
|
||||
upgradeHeader.Set("Set-Cookie",
|
||||
resp.Header.Get(http.CanonicalHeaderKey("Set-Cookie")))
|
||||
|
||||
// Now upgrade the existing incoming request to a WebSocket connection.
|
||||
// Also pass the header that we gathered from the Dial handshake.
|
||||
connPub, err := upgrader.Upgrade(rw, req, upgradeHeader)
|
||||
if err != nil {
|
||||
log.Errorf("Websocketproxy: couldn't upgrade %s", err)
|
||||
http.NotFound(rw, req)
|
||||
return
|
||||
}
|
||||
defer connPub.Close()
|
||||
|
||||
errc := make(chan error, 2)
|
||||
cp := func(dst io.Writer, src io.Reader) {
|
||||
_, err := io.Copy(dst, src)
|
||||
errc <- err
|
||||
}
|
||||
|
||||
// Start our proxy now, everything is ready...
|
||||
go cp(connBackend.UnderlyingConn(), connPub.UnderlyingConn())
|
||||
go cp(connPub.UnderlyingConn(), connBackend.UnderlyingConn())
|
||||
<-errc
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
[backends]{{range .Containers}}
|
||||
[backends.backend-{{getBackend .}}.servers.server-{{.Name | replace "/" "" | replace "." "-"}}]
|
||||
url = "http://{{.NetworkSettings.IPAddress}}:{{getPort .}}"
|
||||
weight = {{getWeight .}}
|
||||
{{end}}
|
||||
|
||||
[frontends]{{range $host, $containers := .Hosts}}
|
||||
[frontends.frontend-{{$host}}]
|
||||
{{$container := index $containers 0}}
|
||||
backend = "backend-{{getBackend $container}}"
|
||||
[frontends.frontend-{{$host}}.routes.route-host-{{$host}}]
|
||||
rule = "Host"
|
||||
value = "{{$host}}.{{$.Domain}}"
|
||||
{{end}}
|
@@ -1,27 +0,0 @@
|
||||
{{$apps := .Applications}}
|
||||
[backends]{{range .Tasks}}
|
||||
[backends.backend{{.AppID | replace "/" "-"}}.servers.server-{{.ID | replace "." "-"}}]
|
||||
url = "http://{{.Host}}:{{getPort .}}"
|
||||
{{$appID := .AppID}}
|
||||
{{range $apps}}
|
||||
{{if eq $appID .ID}}
|
||||
weight = {{getWeight .}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
[frontends]{{ range $app := .Applications}}
|
||||
{{range $prefix := getPrefixes .}}
|
||||
[frontends.frontend{{$app.ID | replace "/" "-"}}{{$prefix | replace "/" "-"}}]
|
||||
backend = "backend{{$app.ID | replace "/" "-"}}"
|
||||
[frontends.frontend-{{getHost $app | replace "/" "-"}}{{$prefix | replace "/" "-"}}.routes.route-prefix{{$prefix | replace "/" "-"}}]
|
||||
rule = "PathPrefix"
|
||||
value = "{{.}}"
|
||||
{{else}}
|
||||
[frontends.frontend{{.ID | replace "/" "-"}}]
|
||||
backend = "backend{{.ID | replace "/" "-"}}"
|
||||
[frontends.frontend-{{getHost $app | replace "/" "-"}}.routes.route-host-{{getHost $app | replace "/" "-"}}]
|
||||
rule = "Host"
|
||||
value = "{{getHost $app | replace "/" "-"}}.{{$.Domain}}"
|
||||
{{end}}
|
||||
{{end}}
|
@@ -1,19 +0,0 @@
|
||||
{{$apps := .Applications}}
|
||||
[backends]{{range .Tasks}}
|
||||
[backends.backend{{.AppID | replace "/" "-"}}.servers.server-{{.ID | replace "." "-"}}]
|
||||
url = "http://{{.Host}}:{{getPort .}}"
|
||||
{{$appID := .AppID}}
|
||||
{{range $apps}}
|
||||
{{if eq $appID .ID}}
|
||||
weight = {{getWeight .}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
[frontends]{{range .Applications}}
|
||||
[frontends.frontend{{.ID | replace "/" "-"}}]
|
||||
backend = "backend{{.ID | replace "/" "-"}}"
|
||||
[frontends.frontend-{{getHost . | replace "/" "-"}}.routes.route-host-{{getHost . | replace "/" "-"}}]
|
||||
rule = "Host"
|
||||
value = "{{getHost . | replace "/" "-"}}.{{$.Domain}}"
|
||||
{{end}}
|
@@ -7,8 +7,14 @@ if ! test -e gen.go; then
|
||||
fi
|
||||
|
||||
rm -f dist/traefik
|
||||
rm -rf Godeps/_workspace/pkg
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
VERSION=$(git rev-parse HEAD)
|
||||
fi
|
||||
|
||||
if [ -z "$DATE" ]; then
|
||||
DATE=$(date -u '+%Y-%m-%d_%I:%M:%S%p')
|
||||
fi
|
||||
|
||||
# Build binaries
|
||||
CGO_ENABLED=0 godep go build -a -installsuffix nocgo -o dist/traefik .
|
||||
|
||||
CGO_ENABLED=0 go build -ldflags "-X main.Version=$VERSION -X main.BuildDate=$DATE" -a -installsuffix nocgo -o dist/traefik .
|
||||
|
@@ -20,11 +20,17 @@ else
|
||||
OS_ARCH_ARG=($2)
|
||||
fi
|
||||
|
||||
if [ -z "$VERSION" ]; then
|
||||
VERSION=$(git rev-parse HEAD)
|
||||
fi
|
||||
|
||||
if [ -z "$DATE" ]; then
|
||||
DATE=$(date -u '+%Y-%m-%d_%I:%M:%S%p')
|
||||
fi
|
||||
|
||||
# Get rid of existing binaries
|
||||
rm -f dist/traefik_*
|
||||
rm -rf Godeps/_workspace/pkg
|
||||
|
||||
# Build binaries
|
||||
GOPATH=`godep path`:$GOPATH gox "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \
|
||||
gox -ldflags "-X main.Version=$VERSION -X main.BuildDate=$DATE" "${OS_PLATFORM_ARG[@]}" "${OS_ARCH_ARG[@]}" \
|
||||
-output="dist/traefik_{{.OS}}-{{.Arch}}"
|
||||
|
||||
|
12
script/dockerversion
Normal file
12
script/dockerversion
Normal file
@@ -0,0 +1,12 @@
|
||||
// AUTOGENERATED FILE; see /go/src/github.com/docker/docker/hack/make/.go-autogen
|
||||
package dockerversion
|
||||
|
||||
var (
|
||||
GITCOMMIT string = "traefik-import"
|
||||
VERSION string = "traefik-import"
|
||||
BUILDTIME string = "traefik-import"
|
||||
|
||||
IAMSTATIC string = "traefik-import"
|
||||
INITSHA1 string = "traefik-import"
|
||||
INITPATH string = "traefik-import"
|
||||
)
|
@@ -5,6 +5,7 @@ set -e
|
||||
DEFAULT_BUNDLES=(
|
||||
validate-gofmt
|
||||
validate-govet
|
||||
generate
|
||||
binary
|
||||
|
||||
test-unit
|
||||
|
@@ -6,5 +6,5 @@ export DEST=.
|
||||
TESTFLAGS="$TESTFLAGS -test.timeout=30m -check.v"
|
||||
|
||||
cd integration
|
||||
GOPATH=`godep path`:$GOPATH go test $TESTFLAGS
|
||||
go test $TESTFLAGS
|
||||
|
||||
|
@@ -17,7 +17,7 @@ find_dirs() {
|
||||
find . -not \( \
|
||||
\( \
|
||||
-path './integration/*' \
|
||||
-o -path './Godeps/*' \
|
||||
-o -path './vendor/*' \
|
||||
-o -path './.git/*' \
|
||||
\) \
|
||||
-prune \
|
||||
@@ -34,7 +34,7 @@ TESTS_FAILED=()
|
||||
|
||||
for dir in $TESTDIRS; do
|
||||
echo '+ go test' $TESTFLAGS "${dir}"
|
||||
godep go test ${TESTFLAGS} ${dir}
|
||||
go test ${TESTFLAGS} ${dir}
|
||||
if [ $? != 0 ]; then
|
||||
TESTS_FAILED+=("$dir")
|
||||
echo
|
||||
|
@@ -3,7 +3,7 @@
|
||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
||||
|
||||
IFS=$'\n'
|
||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^Godeps' || true) )
|
||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor' || true) )
|
||||
unset IFS
|
||||
|
||||
badFiles=()
|
||||
|
@@ -3,7 +3,7 @@
|
||||
source "$(dirname "$BASH_SOURCE")/.validate"
|
||||
|
||||
IFS=$'\n'
|
||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^Godeps/' || true) )
|
||||
files=( $(validate_diff --diff-filter=ACMR --name-only -- '*.go' | grep -v '^vendor/' || true) )
|
||||
unset IFS
|
||||
|
||||
errors=()
|
||||
|
@@ -1,4 +1,4 @@
|
||||
(function () {
|
||||
(function (d3) {
|
||||
'use strict';
|
||||
|
||||
angular.module('traefik.section.health')
|
||||
@@ -6,21 +6,199 @@
|
||||
|
||||
var vm = this;
|
||||
|
||||
vm.health = Health.get();
|
||||
vm.graph = {
|
||||
averageResponseTime: {},
|
||||
totalStatusCodeCount: {}
|
||||
};
|
||||
|
||||
var intervalId = $interval(function () {
|
||||
Health.get(function (health) {
|
||||
vm.graph.totalStatusCodeCount.options = {
|
||||
"chart": {
|
||||
type: 'discreteBarChart',
|
||||
height: 200,
|
||||
margin: {
|
||||
top: 20,
|
||||
right: 20,
|
||||
bottom: 40,
|
||||
left: 55
|
||||
},
|
||||
x: function (d) {
|
||||
return d.label;
|
||||
},
|
||||
y: function (d) {
|
||||
return d.value;
|
||||
},
|
||||
showValues: true,
|
||||
valueFormat: function (d) {
|
||||
return d3.format('d')(d);
|
||||
},
|
||||
transitionDuration: 50,
|
||||
yAxis: {
|
||||
axisLabelDistance: 30
|
||||
}
|
||||
},
|
||||
"title": {
|
||||
"enable": true,
|
||||
"text": "Total Status Code Count",
|
||||
"css": {
|
||||
"textAlign": "center"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
vm.graph.totalStatusCodeCount.data = [
|
||||
{
|
||||
key: "Total Status Code Count",
|
||||
values: [
|
||||
{
|
||||
"label": "200",
|
||||
"value": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* Update Total Status Code Count graph
|
||||
*
|
||||
* @param {Object} totalStatusCodeCount Object from API
|
||||
*/
|
||||
function updateTotalStatusCodeCount(totalStatusCodeCount) {
|
||||
|
||||
// extract values
|
||||
vm.graph.totalStatusCodeCount.data[0].values = [];
|
||||
for (var code in totalStatusCodeCount) {
|
||||
if (totalStatusCodeCount.hasOwnProperty(code)) {
|
||||
vm.graph.totalStatusCodeCount.data[0].values.push({
|
||||
label: code,
|
||||
value: totalStatusCodeCount[code]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update Total Status Code Count graph render
|
||||
if (vm.graph.totalStatusCodeCount.api) {
|
||||
vm.graph.totalStatusCodeCount.api.update();
|
||||
} else {
|
||||
console.error('fail');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vm.graph.averageResponseTime.options = {
|
||||
chart: {
|
||||
type: 'lineChart',
|
||||
height: 200,
|
||||
margin: {
|
||||
top: 20,
|
||||
right: 40,
|
||||
bottom: 40,
|
||||
left: 55
|
||||
},
|
||||
transitionDuration: 50,
|
||||
x: function (d) {
|
||||
return d.x;
|
||||
},
|
||||
y: function (d) {
|
||||
return d.y;
|
||||
},
|
||||
useInteractiveGuideline: true,
|
||||
xAxis: {
|
||||
tickFormat: function (d) {
|
||||
return d3.time.format('%X')(new Date(d));
|
||||
}
|
||||
},
|
||||
yAxis: {
|
||||
tickFormat: function (d) {
|
||||
return d3.format(',.1f')(d);
|
||||
}
|
||||
}
|
||||
},
|
||||
"title": {
|
||||
"enable": true,
|
||||
"text": "Average response time",
|
||||
"css": {
|
||||
"textAlign": "center"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var initialPoint = {
|
||||
x: Date.now() - 3000,
|
||||
y: 0
|
||||
};
|
||||
vm.graph.averageResponseTime.data = [
|
||||
{
|
||||
values: [initialPoint],
|
||||
key: 'Average response time (ms)',
|
||||
type: 'line',
|
||||
color: '#2ca02c'
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* Update average response time graph
|
||||
*
|
||||
* @param {Number} x Coordinate X
|
||||
* @param {Number} y Coordinate Y
|
||||
*/
|
||||
function updateAverageResponseTimeGraph(x, y) {
|
||||
|
||||
// x multiply 1000 by because unix time is in seconds and JS Date are in milliseconds
|
||||
var data = {
|
||||
x: x * 1000,
|
||||
y: y * 1000
|
||||
};
|
||||
vm.graph.averageResponseTime.data[0].values.push(data);
|
||||
// limit graph entries
|
||||
if (vm.graph.averageResponseTime.data[0].values.length > 100) {
|
||||
vm.graph.averageResponseTime.data[0].values.shift();
|
||||
}
|
||||
|
||||
// Update Average Response Time graph render
|
||||
if (vm.graph.averageResponseTime.api) {
|
||||
vm.graph.averageResponseTime.api.update();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load all graph's datas
|
||||
*
|
||||
* @param {Object} health Health data from server
|
||||
*/
|
||||
function loadData(health) {
|
||||
// Load datas and update Average Response Time graph render
|
||||
updateAverageResponseTimeGraph(health.unixtime, health.average_response_time_sec);
|
||||
|
||||
// Load datas and update Total Status Code Count graph render
|
||||
updateTotalStatusCodeCount(health.total_status_code_count);
|
||||
|
||||
// set data's view
|
||||
vm.health = health;
|
||||
}, function (error) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Action when load datas failed
|
||||
*
|
||||
* @param {Object} error Error state object
|
||||
*/
|
||||
function erroData(error) {
|
||||
vm.health = {};
|
||||
$log.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
// first load
|
||||
Health.get(loadData, erroData);
|
||||
|
||||
// Auto refresh data
|
||||
var intervalId = $interval(function () {
|
||||
Health.get(loadData, erroData);
|
||||
}, 3000);
|
||||
|
||||
// Stop auto refresh when page change
|
||||
$scope.$on('$destroy', function () {
|
||||
$interval.cancel(intervalId);
|
||||
});
|
||||
|
||||
}]);
|
||||
|
||||
})();
|
||||
})(d3);
|
||||
|
@@ -2,45 +2,42 @@
|
||||
<h1 class="text-danger">
|
||||
<span class="glyphicon glyphicon-heart" aria-hidden="true"></span> Health
|
||||
</h1>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-6">
|
||||
<div>
|
||||
<nvd3 options="healthCtrl.graph.averageResponseTime.options" data="healthCtrl.graph.averageResponseTime.data" api="healthCtrl.graph.averageResponseTime.api"></nvd3>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<span>Average response time sec :</span><span class="badge">{{healthCtrl.health.average_response_time_sec}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Average response time :</span><span class="badge">{{healthCtrl.health.average_response_time}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Total response time sec :</span><span class="badge">{{healthCtrl.health.total_response_time_sec}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Total response time :</span><span class="badge">{{healthCtrl.health.total_response_time}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Total count :</span><span class="badge">{{healthCtrl.health.total_count}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<span>PID :</span><span class="badge">{{healthCtrl.health.pid}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Uptime :</span><span class="badge">{{healthCtrl.health.uptime}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<div>
|
||||
<nvd3 options="healthCtrl.graph.totalStatusCodeCount.options" data="healthCtrl.graph.totalStatusCodeCount.data" api="healthCtrl.graph.totalStatusCodeCount.api"></nvd3>
|
||||
</div>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<span>Uptime sec :</span><span class="badge">{{healthCtrl.health.uptime_sec}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Time :</span><span class="badge">{{healthCtrl.health.time}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Unixtime :</span><span class="badge">{{healthCtrl.health.unixtime}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Status code count :</span><span class="badge">{{healthCtrl.health.status_code_count}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Total status code count :</span><span class="badge">{{healthCtrl.health.total_status_code_count}}</span>
|
||||
<span>Total count :</span><span class="badge">{{healthCtrl.health.total_count}}</span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<span>Count :</span><span class="badge">{{healthCtrl.health.count}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@@ -9,15 +9,15 @@
|
||||
<td><em>URL</em></td>
|
||||
<td><em>Weight</em></td>
|
||||
</tr>
|
||||
<tr data-ng-repeat="(serverId, server) in backendCtrl.backend.Servers">
|
||||
<tr data-ng-repeat="(serverId, server) in backendCtrl.backend.servers">
|
||||
<td>{{serverId}}</td>
|
||||
<td><code><a data-ng-href="{{server.url}}">{{server.URL}}</a></code></td>
|
||||
<td>{{server.Weight}}</td>
|
||||
<td><code><a data-ng-href="{{server.url}}">{{server.url}}</a></code></td>
|
||||
<td>{{server.weight}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="panel-footer" data-ng-show="backendCtrl.backend.LoadBalancer || backendCtrl.backend.CircuitBreaker">
|
||||
<span data-ng-show="backendCtrl.backend.LoadBalancer" class="label label-success">Load Balancer: {{backendCtrl.backend.LoadBalancer.Method}}</span>
|
||||
<span data-ng-show="backendCtrl.backend.CircuitBreaker" class="label label-success">Circuit Breaker: {{backendCtrl.backend.CircuitBreaker.Expression}}</span>
|
||||
<div class="panel-footer" data-ng-show="backendCtrl.backend.loadBalancer || backendCtrl.backend.circuitBreaker">
|
||||
<span data-ng-show="backendCtrl.backend.loadBalancer" class="label label-success">Load Balancer: {{backendCtrl.backend.loadBalancer.method}}</span>
|
||||
<span data-ng-show="backendCtrl.backend.circuitBreaker" class="label label-success">Circuit Breaker: {{backendCtrl.backend.circuitBreaker.expression}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -9,14 +9,15 @@
|
||||
<td><em>Rule</em></td>
|
||||
<td><em>Value</em></td>
|
||||
</tr>
|
||||
<tr data-ng-repeat="(routeId, route) in frontendCtrl.frontend.Routes">
|
||||
<tr data-ng-repeat="(routeId, route) in frontendCtrl.frontend.routes">
|
||||
<td>{{routeId}}</td>
|
||||
<td>{{route.Rule}}</td>
|
||||
<td><code>{{route.Value}}</code></td>
|
||||
<td>{{route.rule}}</td>
|
||||
<td><code>{{route.value}}</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div data-bg-show="frontendCtrl.frontend.Backend" class="panel-footer">
|
||||
<span class="label label-warning" role="button" data-toggle="collapse" href="#{{frontendCtrl.frontend.Backend}}" aria-expanded="false">{{frontendCtrl.frontend.Backend}}</span>
|
||||
<div data-bg-show="frontendCtrl.frontend.backend" class="panel-footer">
|
||||
<span class="label label-warning" role="button" data-toggle="collapse" href="#{{frontendCtrl.frontend.backend}}" aria-expanded="false">{{frontendCtrl.frontend.backend}}</span>
|
||||
<span data-ng-show="frontendCtrl.frontend.passHostHeader" class="label label-warning">Pass Host Header</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -4,12 +4,12 @@
|
||||
|
||||
<div class="row tabset-row__providers">
|
||||
<div class="col-md-6">
|
||||
<div data-ng-repeat="(frontendId, frontend) in provider.Frontends">
|
||||
<div data-ng-repeat="(frontendId, frontend) in provider.frontends">
|
||||
<frontend-monitor data-provider-id="providerId" data-frontend-id="frontendId" data-frontend="frontend"></frontend-monitor>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div data-ng-repeat="(backendId, backend) in provider.Backends">
|
||||
<div data-ng-repeat="(backendId, backend) in provider.backends">
|
||||
<backend-monitor data-provider-id="providerId" data-backend-id="backendId" data-backend="backend"></backend-monitor>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -5,6 +5,7 @@
|
||||
.module('traefik.section', [
|
||||
'ui.router',
|
||||
'ui.bootstrap',
|
||||
'nvd3',
|
||||
'traefik.section.providers',
|
||||
'traefik.section.health'
|
||||
]);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "traefik",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://github.com/ldez/traefik",
|
||||
"homepage": "http://traefik.io",
|
||||
"authors": [
|
||||
"Fernandez Ludovic <ludovic.fernandez@zenika.com>"
|
||||
],
|
||||
@@ -20,6 +20,7 @@
|
||||
"bootstrap": "~3.3.5",
|
||||
"angular-resource": "~1.4.7",
|
||||
"angular-ui-router": "~0.2.15",
|
||||
"angular-bootstrap": "~0.13.4"
|
||||
"angular-bootstrap": "~0.13.4",
|
||||
"angular-nvd3": "~1.0.2"
|
||||
}
|
||||
}
|
||||
|
1
static/bower_components/angular-nvd3/dist/angular-nvd3.min.js
vendored
Normal file
1
static/bower_components/angular-nvd3/dist/angular-nvd3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
static/bower_components/d3/d3.min.js
vendored
Normal file
5
static/bower_components/d3/d3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
static/bower_components/nvd3/build/nv.d3.min.css
vendored
Normal file
1
static/bower_components/nvd3/build/nv.d3.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
8
static/bower_components/nvd3/build/nv.d3.min.js
vendored
Normal file
8
static/bower_components/nvd3/build/nv.d3.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -13,6 +13,9 @@
|
||||
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="bower_components/angular-bootstrap/ui-bootstrap-csp.css">
|
||||
|
||||
<!-- NVD3 -->
|
||||
<link rel="stylesheet" href="bower_components/nvd3/build/nv.d3.min.css">
|
||||
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
|
||||
@@ -57,6 +60,9 @@
|
||||
<script src="bower_components/angular-resource/angular-resource.min.js"></script>
|
||||
<script src="bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>
|
||||
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script>
|
||||
<script src="bower_components/d3/d3.min.js"></script>
|
||||
<script src="bower_components/nvd3/build/nv.d3.min.js"></script>
|
||||
<script src="bower_components/angular-nvd3/dist/angular-nvd3.min.js"></script>
|
||||
<!-- end vendors -->
|
||||
|
||||
<script src="app/traefik.js"></script>
|
||||
|
@@ -26,4 +26,7 @@ Do `npm install` and `bower install`
|
||||
- [UI Router - Documentation](https://github.com/angular-ui/ui-router/wiki)
|
||||
- [Bootstrap](http://getbootstrap.com)
|
||||
- [Angular Bootstrap](https://angular-ui.github.io/bootstrap)
|
||||
|
||||
- [D3](http://d3js.org)
|
||||
- [D3 - Documentation](https://github.com/mbostock/d3/wiki)
|
||||
- [NVD3](http://nvd3.org)
|
||||
- [Angular nvD3](http://krispo.github.io/angular-nvd3)
|
||||
|
@@ -1,101 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>/ˈTræfɪk/</title>
|
||||
|
||||
<!-- Bootstrap -->
|
||||
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/static/bootstrap/css/bootstrap-theme.min.css">
|
||||
<script src="/static/jquery-2.1.4.min.js"></script>
|
||||
<script src="/static/bootstrap/js/bootstrap.min.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
body {padding-bottom: 70px;}
|
||||
.content {margin:10px;}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<div class="jumbotron">
|
||||
<h1>/ˈTræfɪk/</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-6">
|
||||
<!-- <div class="panel-heading">Frontends</div>
|
||||
<div class="panel-body"> -->
|
||||
{{range $keyProviders, $valueProviders := .Configurations}}
|
||||
{{range $keyFrontends, $valueFrontends := $valueProviders.Frontends}}
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">{{$keyFrontends}} - ({{$keyProviders}})</div>
|
||||
<div class="panel-body">
|
||||
<a class="btn btn-info" role="button" data-toggle="collapse" href="#{{$valueFrontends.Backend}}" aria-expanded="false">
|
||||
{{$valueFrontends.Backend}}
|
||||
</a>
|
||||
</div>
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<td><em>Route</em></td>
|
||||
<td><em>Rule</em></td>
|
||||
<td><em>Value</em></td>
|
||||
</tr>
|
||||
{{range $keyRoutes, $valueRoutes := $valueFrontends.Routes}}
|
||||
<tr>
|
||||
<td>{{$keyRoutes}}</td>
|
||||
<td>{{$valueRoutes.Rule}}</td>
|
||||
<td>{{$valueRoutes.Value}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<!-- <div class="panel-heading">Backends</div>
|
||||
<div class="panel-body"> -->
|
||||
{{range $keyProviders, $valueProviders := .Configurations}}
|
||||
{{range $keyBackends, $valueBackends := $valueProviders.Backends}}
|
||||
<div class="panel panel-primary" id="{{$keyBackends}}">
|
||||
<div class="panel-heading">{{$keyBackends}} - ({{$keyProviders}})</div>
|
||||
<div class="panel-body">
|
||||
{{with $valueBackends.LoadBalancer}}
|
||||
<a class="btn btn-info" role="button">
|
||||
Load Balancer: {{.Method}}
|
||||
</a>
|
||||
{{end}}
|
||||
{{with $valueBackends.CircuitBreaker}}
|
||||
<a class="btn btn-info" role="button">
|
||||
Circuit Breaker: {{.Expression}}
|
||||
</a>
|
||||
{{end}}
|
||||
</div>
|
||||
<table class="table table-striped table-hover">
|
||||
<tr>
|
||||
<td><em>Server</em></td>
|
||||
<td><em>URL</em></td>
|
||||
<td><em>Weight</em></td>
|
||||
</tr>
|
||||
{{range $keyServers, $valueServers := $valueBackends.Servers}}
|
||||
<tr>
|
||||
<td>{{$keyServers}}</td>
|
||||
<td><code><A href="{{$valueServers.URL}}">{{$valueServers.URL}}</A></code></td>
|
||||
<td>{{$valueServers.Weight}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</table>
|
||||
</div>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
14
templates/docker.tmpl
Normal file
14
templates/docker.tmpl
Normal file
@@ -0,0 +1,14 @@
|
||||
[backends]{{range .Containers}}
|
||||
[backends.backend-{{getBackend .}}.servers.server-{{.Name | replace "/" "" | replace "." "-"}}]
|
||||
url = "{{getProtocol .}}://{{.NetworkSettings.IPAddress}}:{{getPort .}}"
|
||||
weight = {{getWeight .}}
|
||||
{{end}}
|
||||
|
||||
[frontends]{{range $frontend, $containers := .Frontends}}
|
||||
[frontends."frontend-{{$frontend}}"]{{$container := index $containers 0}}
|
||||
backend = "backend-{{getBackend $container}}"
|
||||
passHostHeader = {{getPassHostHeader $container}}
|
||||
[frontends."frontend-{{$frontend}}".routes."route-frontend-{{$frontend}}"]
|
||||
rule = "{{getFrontendRule $container}}"
|
||||
value = "{{getFrontendValue $container}}"
|
||||
{{end}}
|
15
templates/marathon.tmpl
Normal file
15
templates/marathon.tmpl
Normal file
@@ -0,0 +1,15 @@
|
||||
{{$apps := .Applications}}
|
||||
[backends]{{range .Tasks}}
|
||||
[backends.backend{{.AppID | replace "/" "-"}}.servers.server-{{.ID | replace "." "-"}}]
|
||||
url = "{{getProtocol . $apps}}://{{.Host}}:{{getPort .}}"
|
||||
weight = {{getWeight . $apps}}
|
||||
{{end}}
|
||||
|
||||
[frontends]{{range .Applications}}
|
||||
[frontends.frontend{{.ID | replace "/" "-"}}]
|
||||
backend = "backend{{.ID | replace "/" "-"}}"
|
||||
passHostHeader = {{getPassHostHeader .}}
|
||||
[frontends.frontend-{{.ID | replace "/" ""}}.routes.route-host-{{.ID | replace "/" ""}}]
|
||||
rule = "{{getFrontendRule .}}"
|
||||
value = "{{getFrontendValue .}}"
|
||||
{{end}}
|
21
tests/traefik.crt
Normal file
21
tests/traefik.crt
Normal file
@@ -0,0 +1,21 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDXTCCAkWgAwIBAgIJAPPVb4fq4kkvMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
|
||||
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
||||
aWRnaXRzIFB0eSBMdGQwHhcNMTUxMDE5MTk0MTU4WhcNMTYxMDE4MTk0MTU4WjBF
|
||||
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
|
||||
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
|
||||
CgKCAQEAsPnpfnUPbQxSu3oq38OaX/Q6LKZ5gnS04F8kREF2RvCDMWiKOWru+hXb
|
||||
udkwU7Fx+7BcDBGsnJGFpY23dDcRurxF1DVs1jIFukH/vbYyHE8JQEgvOGSpDEiv
|
||||
rfbcxqK8E/VMrI10eXYGxWzaTFWQOND2PAJ1b5JvZrrzc8rfJ7h5Q24GKnw1999t
|
||||
hwsZgpUOh9te7fz1M4XxxRRoliMg0oH9EV3P9Yqq635tjWOix8PcnpcqnRKXVDhk
|
||||
TcNtE+45RsPoSgM6nkiXt8HP4afaVUAGAzF41kDm94SNexcyk7gyVsLs2cEI61Eu
|
||||
mhvpP3z91md+eAa3If7kU1w70WiY1wIDAQABo1AwTjAdBgNVHQ4EFgQUue6v2TkZ
|
||||
1oR0ZzEnnxfKdsGuBPMwHwYDVR0jBBgwFoAUue6v2TkZ1oR0ZzEnnxfKdsGuBPMw
|
||||
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAk+xxO8gC40R7+5WVtWvA
|
||||
+chNsOoxKyFBOPvGzrYGQbt4OBWKrwQmMXSY3VnjY4GzVaZpOCJOxnupKfZrK4AP
|
||||
G+M+NI+J6fHJRCQdov7Xoje5M14FmgjRiLg+haDZhh//11C7P6MQPAzGNUTpUyqV
|
||||
Hsi/wwCYvre5bApb/4uDkDlZkLrgN4e1q8+gh6XLj8NPEOEBEI4VpMVoieC1PwnK
|
||||
pRfNlTsEhyjeMmOllw9fBKMEvEf1BKsJGaKmQ7zCr1nWznCxyI1Fuf66TfmL8/up
|
||||
lK6sQysLEOIgn2gZEjQz4O/9Jj9v8+TvyP4GZIDsCiv33AaeKJVuSkoeCH0Ls2V8
|
||||
aQ==
|
||||
-----END CERTIFICATE-----
|
28
tests/traefik.key
Normal file
28
tests/traefik.key
Normal file
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCw+el+dQ9tDFK7
|
||||
eirfw5pf9DospnmCdLTgXyREQXZG8IMxaIo5au76Fdu52TBTsXH7sFwMEayckYWl
|
||||
jbd0NxG6vEXUNWzWMgW6Qf+9tjIcTwlASC84ZKkMSK+t9tzGorwT9UysjXR5dgbF
|
||||
bNpMVZA40PY8AnVvkm9muvNzyt8nuHlDbgYqfDX3322HCxmClQ6H217t/PUzhfHF
|
||||
FGiWIyDSgf0RXc/1iqrrfm2NY6LHw9yelyqdEpdUOGRNw20T7jlGw+hKAzqeSJe3
|
||||
wc/hp9pVQAYDMXjWQOb3hI17FzKTuDJWwuzZwQjrUS6aG+k/fP3WZ354Brch/uRT
|
||||
XDvRaJjXAgMBAAECggEAHvnvO5ojtBOXG4d7n6TuDWODFzOgSwxAaJFemK/Ykvwg
|
||||
CnLg1sH3yEAxMGtqgQurBsHMqrQhQVpbSSnv9WB6MvQnSMh9H1SsGfjZWYxdYwUW
|
||||
enDoCvfbevHyBgISjJYJU3j5Da7It0XIU6AE6Z2EW91/a+uGQJwh8ZpBaIAW5S2j
|
||||
B3k+bASANtwEcDdhGE7iLYeHiAttZo89oSSFZP/mwh84pIU29zUVUtsUaHXrob0p
|
||||
iyGXKPa8NqTvIsbX5Kh/lbbCO4KwsOqgs/eqL7cLSv2VfTmSQCJz+ikiVzcw/vJU
|
||||
PaT9H4SCBLP73/Gyjf5P14esWvprPQ3ZnWNNDDGWsQKBgQDoWqxQUy6PKY9or7QH
|
||||
M985y52Y0QlWdmRaLc8gxfWLU4/3Wn0NH1flkFXJ5X9uZFNoGMQpidJBajepzkNO
|
||||
/54V+1NCLUWl7SE5gMeFG8QtEE7ISyjut71CUDSn5mOp7EBARmqRpMZhmXT42RZi
|
||||
1zVDkG08ArKdH0Jnvkq5lWHGbwKBgQDC/IYJXkd27XZO+Ti8TdzaU+SSJV26aY++
|
||||
0N4pzq0cC6IWadHugH/XrgkfH+ImPzkf6XHrCSqSipJJLZMd473/8IjdOsf54wDP
|
||||
/yHKPXWhfC4W2L+6+l34Jo/ebnuDVvDme1nKLcdmxhwz4YZfg/TYbWaFzANrl3St
|
||||
beGg9ENIGQKBgBr6/GtPXWauUsK7NFJpyY/yfthR3Z22nayDCTwrAHovN9ZnIYI2
|
||||
k4RKoEuTZJqy96Rsy8pvAIUsCk6jbtlrgTXYOzDCBQZhZKxCsehY8wywihVj9NrT
|
||||
ZxyeJ58fd48xqbxM8O78jTSkFxsWSi0sBDlWOfjv70GjcZiOVir6l6HtAoGBAJeA
|
||||
MAENcQeV4AviltOwx/4Xmwx23gmeRaMklMn1HQoie9FgbU4cJ7kEL3AwjL3c99y0
|
||||
vN+7Ion0A0+6iol5z8ISObVzG7gsShBSkwWZlVFgtErqJKb6K5NJGxXf0DYvkkPy
|
||||
6cQup7VSDs282HRUiiSzdCpXZvztFCpAq0QtJi3ZAoGACjtJ7zEVs0hB7+sCq/SI
|
||||
UHjjv/fjGSm1TVDP46Joqbm62FRdYkEhd+pGMjtGs80OhM+psTZIqe/fgKdKl5yX
|
||||
nS9m6f4ny6XCcilfI3+bxXtsmWnpQnybSU2goe2n+Eoi3RcEB68Hp8U0aPjgDULM
|
||||
9YDU/ZMupHh/eT79n67QIXw=
|
||||
-----END PRIVATE KEY-----
|
39
tests/whoami.json
Normal file
39
tests/whoami.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"id": "whoami",
|
||||
"cpus": 0.1,
|
||||
"mem": 64.0,
|
||||
"instances": 3,
|
||||
"container": {
|
||||
"type": "DOCKER",
|
||||
"docker": {
|
||||
"image": "emilevauge/whoami",
|
||||
"network": "BRIDGE",
|
||||
"portMappings": [
|
||||
{ "containerPort": 80, "hostPort": 0, "protocol": "tcp" }
|
||||
],
|
||||
"parameters": [{
|
||||
"key": "log-driver",
|
||||
"value": "gelf"
|
||||
}, {
|
||||
"key": "log-opt",
|
||||
"value": "gelf-address=udp://172.17.42.1:12201"
|
||||
}]
|
||||
}
|
||||
},
|
||||
"healthChecks": [
|
||||
{
|
||||
"protocol": "HTTP",
|
||||
"portIndex": 0,
|
||||
"path": "/",
|
||||
"gracePeriodSeconds": 5,
|
||||
"intervalSeconds": 20,
|
||||
"maxConsecutiveFailures": 3
|
||||
}
|
||||
],
|
||||
"labels": {
|
||||
"traefik.weight": "1",
|
||||
"traefik.protocole": "https",
|
||||
"traefik.frontend.rule": "Path",
|
||||
"traefik.frontend.value": "/test"
|
||||
}
|
||||
}
|
107
traefik.go
107
traefik.go
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
fmtlog "log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/codegangsta/negroni"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/emilevauge/traefik/middlewares"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/mailgun/manners"
|
||||
@@ -24,38 +23,29 @@ import (
|
||||
"github.com/mailgun/oxy/forward"
|
||||
"github.com/mailgun/oxy/roundrobin"
|
||||
"github.com/thoas/stats"
|
||||
"github.com/unrolled/render"
|
||||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
globalConfigFile = kingpin.Arg("conf", "Main configration file.").Default("traefik.toml").String()
|
||||
version = kingpin.Flag("version", "Get Version.").Short('v').Bool()
|
||||
currentConfigurations = make(configs)
|
||||
metrics = stats.New()
|
||||
oxyLogger = &OxyLogger{}
|
||||
templatesRenderer = render.New(render.Options{
|
||||
Directory: "templates",
|
||||
Asset: Asset,
|
||||
AssetNames: AssetNames,
|
||||
})
|
||||
)
|
||||
|
||||
type configMessage struct {
|
||||
providerName string
|
||||
configuration *Configuration
|
||||
}
|
||||
|
||||
type configs map[string]*Configuration
|
||||
|
||||
func main() {
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
kingpin.Version(Version + " built on the " + BuildDate)
|
||||
kingpin.Parse()
|
||||
fmtlog.SetFlags(fmtlog.Lshortfile | fmtlog.LstdFlags)
|
||||
var srv *manners.GracefulServer
|
||||
var configurationRouter *mux.Router
|
||||
var configurationChan = make(chan configMessage, 10)
|
||||
defer close(configurationChan)
|
||||
var configurationChanValidated = make(chan configMessage, 10)
|
||||
defer close(configurationChanValidated)
|
||||
var sigs = make(chan os.Signal, 1)
|
||||
defer close(sigs)
|
||||
var stopChan = make(chan bool)
|
||||
@@ -88,16 +78,37 @@ func main() {
|
||||
} else {
|
||||
log.SetFormatter(&log.TextFormatter{FullTimestamp: true, DisableSorting: true})
|
||||
}
|
||||
log.Debugf("Global configuration loaded %s", spew.Sdump(globalConfiguration))
|
||||
log.Debugf("Global configuration loaded %+v", globalConfiguration)
|
||||
configurationRouter = LoadDefaultConfig(globalConfiguration)
|
||||
|
||||
// listen new configurations from providers
|
||||
go func() {
|
||||
|
||||
lastReceivedConfiguration := time.Unix(0, 0)
|
||||
lastConfigs := make(map[string]*configMessage)
|
||||
for {
|
||||
configMsg := <-configurationChan
|
||||
log.Infof("Configuration receveived from provider %s: %#v", configMsg.providerName, configMsg.configuration)
|
||||
log.Debugf("Configuration %s", spew.Sdump(configMsg.configuration))
|
||||
lastConfigs[configMsg.providerName] = &configMsg
|
||||
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(globalConfiguration.ProvidersThrottleDuration))) {
|
||||
log.Infof("Last %s config received more than %s, OK", configMsg.providerName, globalConfiguration.ProvidersThrottleDuration)
|
||||
// last config received more than n s ago
|
||||
configurationChanValidated <- configMsg
|
||||
} else {
|
||||
log.Infof("Last %s config received less than %s, waiting...", configMsg.providerName, globalConfiguration.ProvidersThrottleDuration)
|
||||
go func() {
|
||||
<-time.After(globalConfiguration.ProvidersThrottleDuration)
|
||||
if time.Now().After(lastReceivedConfiguration.Add(time.Duration(globalConfiguration.ProvidersThrottleDuration))) {
|
||||
log.Infof("Waited for %s config, OK", configMsg.providerName)
|
||||
configurationChanValidated <- *lastConfigs[configMsg.providerName]
|
||||
}
|
||||
}()
|
||||
}
|
||||
lastReceivedConfiguration = time.Now()
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
for {
|
||||
configMsg := <-configurationChanValidated
|
||||
if configMsg.configuration == nil {
|
||||
log.Info("Skipping empty configuration")
|
||||
} else if reflect.DeepEqual(currentConfigurations[configMsg.providerName], configMsg.configuration) {
|
||||
@@ -115,10 +126,13 @@ func main() {
|
||||
currentConfigurations = newConfigurations
|
||||
configurationRouter = newConfigurationRouter
|
||||
oldServer := srv
|
||||
newsrv := prepareServer(configurationRouter, globalConfiguration, oldServer, loggerMiddleware, metrics)
|
||||
newsrv, err := prepareServer(configurationRouter, globalConfiguration, oldServer, loggerMiddleware, metrics)
|
||||
if err != nil {
|
||||
log.Fatal("Error preparing server: ", err)
|
||||
}
|
||||
go startServer(newsrv, globalConfiguration)
|
||||
srv = newsrv
|
||||
time.Sleep(2 * time.Second)
|
||||
time.Sleep(1 * time.Second)
|
||||
if oldServer != nil {
|
||||
log.Info("Stopping old server")
|
||||
oldServer.Close()
|
||||
@@ -182,37 +196,54 @@ func main() {
|
||||
|
||||
//negroni.Use(middlewares.NewCircuitBreaker(oxyLogger))
|
||||
//negroni.Use(middlewares.NewRoutes(configurationRouter))
|
||||
srv = prepareServer(configurationRouter, globalConfiguration, nil, loggerMiddleware, metrics)
|
||||
|
||||
var er error
|
||||
srv, er = prepareServer(configurationRouter, globalConfiguration, nil, loggerMiddleware, metrics)
|
||||
if er != nil {
|
||||
log.Fatal("Error preparing server: ", er)
|
||||
}
|
||||
go startServer(srv, globalConfiguration)
|
||||
|
||||
<-stopChan
|
||||
log.Info("Shutting down")
|
||||
}
|
||||
|
||||
func createTLSConfig(certFile string, keyFile string) (*tls.Config, error) {
|
||||
config := &tls.Config{}
|
||||
if config.NextProtos == nil {
|
||||
config.NextProtos = []string{"http/1.1"}
|
||||
}
|
||||
|
||||
var err error
|
||||
config.Certificates = make([]tls.Certificate, 1)
|
||||
if len(certFile) > 0 && len(keyFile) > 0 {
|
||||
config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func startServer(srv *manners.GracefulServer, globalConfiguration *GlobalConfiguration) {
|
||||
log.Info("Starting server")
|
||||
log.Debugf("Server %s", spew.Sdump(srv))
|
||||
if len(globalConfiguration.CertFile) > 0 && len(globalConfiguration.KeyFile) > 0 {
|
||||
err := srv.ListenAndServeTLS(globalConfiguration.CertFile, globalConfiguration.KeyFile)
|
||||
if err != nil {
|
||||
netOpError, ok := err.(*net.OpError)
|
||||
if ok && netOpError.Err.Error() != "use of closed network connection" {
|
||||
log.Fatal("Error creating server: ", err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err := srv.ListenAndServe()
|
||||
if err != nil {
|
||||
netOpError, ok := err.(*net.OpError)
|
||||
if ok && netOpError.Err.Error() != "use of closed network connection" {
|
||||
log.Fatal("Error creating server: ", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
log.Info("Server stopped")
|
||||
}
|
||||
|
||||
func prepareServer(router *mux.Router, globalConfiguration *GlobalConfiguration, oldServer *manners.GracefulServer, middlewares ...negroni.Handler) *manners.GracefulServer {
|
||||
func prepareServer(router *mux.Router, globalConfiguration *GlobalConfiguration, oldServer *manners.GracefulServer, middlewares ...negroni.Handler) (*manners.GracefulServer, error) {
|
||||
log.Info("Preparing server")
|
||||
// middlewares
|
||||
var negroni = negroni.New()
|
||||
@@ -220,23 +251,29 @@ func prepareServer(router *mux.Router, globalConfiguration *GlobalConfiguration,
|
||||
negroni.Use(middleware)
|
||||
}
|
||||
negroni.UseHandler(router)
|
||||
tlsConfig, err := createTLSConfig(globalConfiguration.CertFile, globalConfiguration.KeyFile)
|
||||
if err != nil {
|
||||
log.Fatalf("Error creating TLS config %s", err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if oldServer == nil {
|
||||
return manners.NewWithServer(
|
||||
&http.Server{
|
||||
Addr: globalConfiguration.Port,
|
||||
Handler: negroni,
|
||||
})
|
||||
TLSConfig: tlsConfig,
|
||||
}), nil
|
||||
} else {
|
||||
server, err := oldServer.HijackListener(&http.Server{
|
||||
Addr: globalConfiguration.Port,
|
||||
Handler: negroni,
|
||||
}, nil)
|
||||
}, tlsConfig)
|
||||
if err != nil {
|
||||
log.Fatalf("Error hijacking server %s", err)
|
||||
return nil
|
||||
return nil, err
|
||||
} else {
|
||||
return server
|
||||
return server, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,7 +285,7 @@ func LoadConfig(configurations configs, globalConfiguration *GlobalConfiguration
|
||||
for _, configuration := range configurations {
|
||||
for frontendName, frontend := range configuration.Frontends {
|
||||
log.Debugf("Creating frontend %s", frontendName)
|
||||
fwd, _ := forward.New(forward.Logger(oxyLogger))
|
||||
fwd, _ := forward.New(forward.Logger(oxyLogger), forward.PassHostHeader(frontend.PassHostHeader))
|
||||
newRoute := router.NewRoute().Name(frontendName)
|
||||
for routeName, route := range frontend.Routes {
|
||||
log.Debugf("Creating route %s %s:%s", routeName, route.Rule, route.Value)
|
||||
@@ -281,7 +318,7 @@ func LoadConfig(configurations configs, globalConfiguration *GlobalConfiguration
|
||||
}
|
||||
case wrr:
|
||||
log.Infof("Creating load-balancer wrr")
|
||||
lb = rr
|
||||
lb = middlewares.NewWebsocketUpgrader(rr)
|
||||
for serverName, server := range configuration.Backends[frontend.Backend].Servers {
|
||||
url, err := url.Parse(server.URL)
|
||||
if err != nil {
|
||||
|
@@ -44,6 +44,16 @@
|
||||
# CertFile = "traefik.crt"
|
||||
# KeyFile = "traefik.key"
|
||||
|
||||
# Backends throttle duration: minimum duration between 2 events from providers
|
||||
# before applying a new configuration. It avoids unnecessary reloads if multiples events
|
||||
# are sent in a short amount of time.
|
||||
#
|
||||
# Optional
|
||||
# Default: "2s"
|
||||
#
|
||||
# ProvidersThrottleDuration = "5s"
|
||||
|
||||
|
||||
################################################################
|
||||
# Web configuration backend
|
||||
################################################################
|
||||
@@ -346,6 +356,7 @@
|
||||
# value = "test.localhost"
|
||||
# [frontends.frontend2]
|
||||
# backend = "backend1"
|
||||
# passHostHeader = true
|
||||
# [frontends.frontend2.routes.test_2]
|
||||
# rule = "Path"
|
||||
# value = "/test"
|
||||
|
6
version.go
Normal file
6
version.go
Normal file
@@ -0,0 +1,6 @@
|
||||
package main
|
||||
|
||||
var (
|
||||
Version = ""
|
||||
BuildDate = ""
|
||||
)
|
84
web.go
84
web.go
@@ -9,6 +9,7 @@ import (
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/elazarl/go-bindata-assetfs"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/unrolled/render"
|
||||
)
|
||||
|
||||
type WebProvider struct {
|
||||
@@ -16,6 +17,12 @@ type WebProvider struct {
|
||||
CertFile, KeyFile string
|
||||
}
|
||||
|
||||
var (
|
||||
templatesRenderer = render.New(render.Options{
|
||||
Directory: "nowhere",
|
||||
})
|
||||
)
|
||||
|
||||
func (provider *WebProvider) Provide(configurationChan chan<- configMessage) error {
|
||||
systemRouter := mux.NewRouter()
|
||||
|
||||
@@ -51,6 +58,8 @@ func (provider *WebProvider) Provide(configurationChan chan<- configMessage) err
|
||||
systemRouter.Methods("GET").Path("/api/providers/{provider}/backends/{backend}/servers/{server}").HandlerFunc(getServerHandler)
|
||||
systemRouter.Methods("GET").Path("/api/providers/{provider}/frontends").HandlerFunc(getFrontendsHandler)
|
||||
systemRouter.Methods("GET").Path("/api/providers/{provider}/frontends/{frontend}").HandlerFunc(getFrontendHandler)
|
||||
systemRouter.Methods("GET").Path("/api/providers/{provider}/frontends/{frontend}/routes").HandlerFunc(getRoutesHandler)
|
||||
systemRouter.Methods("GET").Path("/api/providers/{provider}/frontends/{frontend}/routes/{route}").HandlerFunc(getRouteHandler)
|
||||
|
||||
// Expose dashboard
|
||||
systemRouter.Methods("GET").Path("/").HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
|
||||
@@ -115,29 +124,6 @@ func getBackendHandler(response http.ResponseWriter, request *http.Request) {
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
|
||||
func getFrontendsHandler(response http.ResponseWriter, request *http.Request) {
|
||||
vars := mux.Vars(request)
|
||||
providerID := vars["provider"]
|
||||
if provider, ok := currentConfigurations[providerID]; ok {
|
||||
templatesRenderer.JSON(response, http.StatusOK, provider.Frontends)
|
||||
} else {
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
}
|
||||
|
||||
func getFrontendHandler(response http.ResponseWriter, request *http.Request) {
|
||||
vars := mux.Vars(request)
|
||||
providerID := vars["provider"]
|
||||
frontendID := vars["frontend"]
|
||||
if provider, ok := currentConfigurations[providerID]; ok {
|
||||
if frontend, ok := provider.Frontends[frontendID]; ok {
|
||||
templatesRenderer.JSON(response, http.StatusOK, frontend)
|
||||
return
|
||||
}
|
||||
}
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
|
||||
func getServersHandler(response http.ResponseWriter, request *http.Request) {
|
||||
vars := mux.Vars(request)
|
||||
providerID := vars["provider"]
|
||||
@@ -166,3 +152,55 @@ func getServerHandler(response http.ResponseWriter, request *http.Request) {
|
||||
}
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
|
||||
func getFrontendsHandler(response http.ResponseWriter, request *http.Request) {
|
||||
vars := mux.Vars(request)
|
||||
providerID := vars["provider"]
|
||||
if provider, ok := currentConfigurations[providerID]; ok {
|
||||
templatesRenderer.JSON(response, http.StatusOK, provider.Frontends)
|
||||
} else {
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
}
|
||||
|
||||
func getFrontendHandler(response http.ResponseWriter, request *http.Request) {
|
||||
vars := mux.Vars(request)
|
||||
providerID := vars["provider"]
|
||||
frontendID := vars["frontend"]
|
||||
if provider, ok := currentConfigurations[providerID]; ok {
|
||||
if frontend, ok := provider.Frontends[frontendID]; ok {
|
||||
templatesRenderer.JSON(response, http.StatusOK, frontend)
|
||||
return
|
||||
}
|
||||
}
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
|
||||
func getRoutesHandler(response http.ResponseWriter, request *http.Request) {
|
||||
vars := mux.Vars(request)
|
||||
providerID := vars["provider"]
|
||||
frontendID := vars["frontend"]
|
||||
if provider, ok := currentConfigurations[providerID]; ok {
|
||||
if frontend, ok := provider.Frontends[frontendID]; ok {
|
||||
templatesRenderer.JSON(response, http.StatusOK, frontend.Routes)
|
||||
return
|
||||
}
|
||||
}
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
|
||||
func getRouteHandler(response http.ResponseWriter, request *http.Request) {
|
||||
vars := mux.Vars(request)
|
||||
providerID := vars["provider"]
|
||||
frontendID := vars["frontend"]
|
||||
routeID := vars["route"]
|
||||
if provider, ok := currentConfigurations[providerID]; ok {
|
||||
if frontend, ok := provider.Frontends[frontendID]; ok {
|
||||
if route, ok := frontend.Routes[routeID]; ok {
|
||||
templatesRenderer.JSON(response, http.StatusOK, route)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
http.NotFound(response, request)
|
||||
}
|
||||
|
Reference in New Issue
Block a user