Add possibility to use BindPort IPAddress 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
46a7860427
commit
5ea761e19f
4 changed files with 129 additions and 109 deletions
|
@ -614,6 +614,13 @@ watch = true
|
|||
#
|
||||
exposedbydefault = true
|
||||
|
||||
# Use the IP address from the binded port instead of the inner network one. For specific use-case :)
|
||||
#
|
||||
# Optional
|
||||
# Default: false
|
||||
#
|
||||
usebindportip = true
|
||||
|
||||
# Enable docker TLS connection
|
||||
#
|
||||
# [docker.tls]
|
||||
|
|
210
glide.lock
generated
210
glide.lock
generated
|
@ -1,10 +1,10 @@
|
|||
hash: 809b3fa812ca88940fdc15530804a4bcd881708e4819fed5aa45c42c871ba5cf
|
||||
updated: 2016-09-19T16:36:41.975117683+02:00
|
||||
updated: 2016-09-20T14:50:04.029710103+02:00
|
||||
imports:
|
||||
- name: github.com/abbot/go-http-auth
|
||||
version: cb4372376e1e00e9f6ab9ec142e029302c9e7140
|
||||
- name: github.com/boltdb/bolt
|
||||
version: fff57c100f4dea1905678da7e90d92429dff2904
|
||||
version: 5cc10bbbc5c141029940133bb33c9e969512a698
|
||||
- name: github.com/BurntSushi/toml
|
||||
version: 99064174e013895bbd9b025c31100bd1d9b590ca
|
||||
- name: github.com/BurntSushi/ty
|
||||
|
@ -14,9 +14,9 @@ imports:
|
|||
- name: github.com/codahale/hdrhistogram
|
||||
version: f8ad88b59a584afeee9d334eff879b104439117b
|
||||
- name: github.com/codegangsta/cli
|
||||
version: d53eb991652b1d438abdd34ce4bfa3ef1539108e
|
||||
version: 1efa31f08b9333f1bd4882d61f9d668a70cd902e
|
||||
- name: github.com/codegangsta/negroni
|
||||
version: 3f7ce7b928e14ff890b067e5bbbc80af73690a9c
|
||||
version: dc6b9d037e8dab60cbfc09c61d6932537829be8b
|
||||
- name: github.com/containous/flaeg
|
||||
version: a731c034dda967333efce5f8d276aeff11f8ff87
|
||||
- name: github.com/containous/mux
|
||||
|
@ -24,122 +24,122 @@ imports:
|
|||
- name: github.com/containous/staert
|
||||
version: 044bdfee6c8f5e8fb71f70d5ba1cf4cb11a94e97
|
||||
- name: github.com/coreos/etcd
|
||||
version: a70513621cf914e2de4dbf90d8a0328e807ffd12
|
||||
version: 1c9e0a0e33051fed6c05c141e6fcbfe5c7f2a899
|
||||
subpackages:
|
||||
- client
|
||||
- pkg/pathutil
|
||||
- pkg/types
|
||||
- name: github.com/davecgh/go-spew
|
||||
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
|
||||
version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d
|
||||
subpackages:
|
||||
- spew
|
||||
- name: github.com/docker/distribution
|
||||
version: b6e0cfbdaa1ddc3a17c95142c7bf6e42c5567370
|
||||
version: 857d0f15c0a4d8037175642e0ca3660829551cb5
|
||||
subpackages:
|
||||
- context
|
||||
- digest
|
||||
- reference
|
||||
- digest
|
||||
- registry/api/errcode
|
||||
- registry/api/v2
|
||||
- registry/client
|
||||
- registry/client/auth
|
||||
- registry/client/transport
|
||||
- registry/client
|
||||
- context
|
||||
- registry/api/v2
|
||||
- registry/storage/cache
|
||||
- registry/storage/cache/memory
|
||||
- uuid
|
||||
- name: github.com/docker/docker
|
||||
version: 534753663161334baba06f13b8efa4cad22b5bc5
|
||||
subpackages:
|
||||
- api/types/backend
|
||||
- builder
|
||||
- builder/dockerignore
|
||||
- namesgenerator
|
||||
- pkg/namesgenerator
|
||||
- pkg/random
|
||||
- pkg/urlutil
|
||||
- cliconfig
|
||||
- cliconfig/configfile
|
||||
- daemon/graphdriver
|
||||
- image
|
||||
- image/v1
|
||||
- layer
|
||||
- namesgenerator
|
||||
- opts
|
||||
- pkg/archive
|
||||
- pkg/chrootarchive
|
||||
- pkg/fileutils
|
||||
- pkg/gitutils
|
||||
- pkg/homedir
|
||||
- pkg/httputils
|
||||
- pkg/idtools
|
||||
- pkg/ioutils
|
||||
- pkg/jsonlog
|
||||
- pkg/jsonmessage
|
||||
- pkg/longpath
|
||||
- pkg/mflag
|
||||
- pkg/mount
|
||||
- pkg/namesgenerator
|
||||
- pkg/plugins
|
||||
- pkg/plugins/transport
|
||||
- pkg/pools
|
||||
- pkg/progress
|
||||
- pkg/promise
|
||||
- pkg/random
|
||||
- pkg/reexec
|
||||
- pkg/signal
|
||||
- pkg/stdcopy
|
||||
- pkg/streamformatter
|
||||
- pkg/stringid
|
||||
- pkg/symlink
|
||||
- pkg/system
|
||||
- pkg/tarsum
|
||||
- pkg/term
|
||||
- pkg/term/windows
|
||||
- pkg/urlutil
|
||||
- reference
|
||||
- registry
|
||||
- runconfig/opts
|
||||
- pkg/homedir
|
||||
- pkg/jsonlog
|
||||
- pkg/system
|
||||
- pkg/term/windows
|
||||
- image
|
||||
- image/v1
|
||||
- pkg/ioutils
|
||||
- opts
|
||||
- pkg/httputils
|
||||
- pkg/mflag
|
||||
- pkg/stringid
|
||||
- pkg/tarsum
|
||||
- pkg/mount
|
||||
- pkg/signal
|
||||
- builder
|
||||
- builder/dockerignore
|
||||
- pkg/archive
|
||||
- pkg/fileutils
|
||||
- pkg/progress
|
||||
- pkg/streamformatter
|
||||
- layer
|
||||
- pkg/longpath
|
||||
- api/types/backend
|
||||
- pkg/chrootarchive
|
||||
- pkg/gitutils
|
||||
- pkg/symlink
|
||||
- pkg/idtools
|
||||
- pkg/pools
|
||||
- daemon/graphdriver
|
||||
- pkg/reexec
|
||||
- pkg/plugins
|
||||
- pkg/plugins/transport
|
||||
- name: github.com/docker/engine-api
|
||||
version: 62043eb79d581a32ea849645277023c550732e52
|
||||
subpackages:
|
||||
- client
|
||||
- client/transport
|
||||
- client/transport/cancellable
|
||||
- types
|
||||
- types/blkiodev
|
||||
- types/container
|
||||
- types/events
|
||||
- types/filters
|
||||
- types/container
|
||||
- types/network
|
||||
- client/transport
|
||||
- client/transport/cancellable
|
||||
- types/reference
|
||||
- types/registry
|
||||
- types/strslice
|
||||
- types/swarm
|
||||
- types/time
|
||||
- types/versions
|
||||
- types/blkiodev
|
||||
- types/strslice
|
||||
- name: github.com/docker/go-connections
|
||||
version: 988efe982fdecb46f01d53465878ff1f2ff411ce
|
||||
version: 990a1a1a70b0da4c4cb70e117971a4f0babfbf1a
|
||||
subpackages:
|
||||
- nat
|
||||
- sockets
|
||||
- tlsconfig
|
||||
- nat
|
||||
- name: github.com/docker/go-units
|
||||
version: f2145db703495b2e525c59662db69a7344b00bb8
|
||||
version: f2d77a61e3c169b43402a0a1e84f06daf29b8190
|
||||
- name: github.com/docker/libcompose
|
||||
version: d1876c1d68527a49c0aac22a0b161acc7296b740
|
||||
subpackages:
|
||||
- config
|
||||
- docker
|
||||
- project
|
||||
- project/events
|
||||
- project/options
|
||||
- utils
|
||||
- yaml
|
||||
- docker/builder
|
||||
- docker/client
|
||||
- docker/network
|
||||
- labels
|
||||
- logger
|
||||
- lookup
|
||||
- project
|
||||
- project/events
|
||||
- project/options
|
||||
- utils
|
||||
- version
|
||||
- yaml
|
||||
- name: github.com/docker/libkv
|
||||
version: 3fce6a0f26e07da3eac45796a8e255547a47a750
|
||||
version: aabc039ad04deb721e234f99cd1b4aa28ac71a40
|
||||
subpackages:
|
||||
- store
|
||||
- store/boltdb
|
||||
|
@ -149,7 +149,7 @@ imports:
|
|||
- name: github.com/donovanhide/eventsource
|
||||
version: fd1de70867126402be23c306e1ce32828455d85b
|
||||
- name: github.com/elazarl/go-bindata-assetfs
|
||||
version: 9a6736ed45b44bf3835afeebb3034b57ed329f3e
|
||||
version: 57eb5e1fc594ad4b0b1dbea7b286d299e0cb43c2
|
||||
- name: github.com/emilevauge/backoff
|
||||
version: fa0423e7916ea96a4e9789a3710c8e7cb94ecc42
|
||||
- name: github.com/gambol99/go-marathon
|
||||
|
@ -157,27 +157,28 @@ imports:
|
|||
- name: github.com/go-check/check
|
||||
version: 4f90aeace3a26ad7021961c297b22c42160c7b25
|
||||
- name: github.com/gogo/protobuf
|
||||
version: a11c89fbb0ad4acfa8abc4a4d5f7e27c477169b1
|
||||
version: e57a569e1882958f6b188cb42231d6db87701f2a
|
||||
subpackages:
|
||||
- proto
|
||||
- name: github.com/golang/glog
|
||||
version: 23def4e6c14b4da8ac2ed8007337bc5eb5007998
|
||||
version: fca8c8854093a154ff1eb580aae10276ad6b1b5f
|
||||
- name: github.com/google/go-querystring
|
||||
version: 9235644dd9e52eeae6fa48efd539fdc351a0af53
|
||||
subpackages:
|
||||
- query
|
||||
- name: github.com/gorilla/context
|
||||
version: 08b5f424b9271eedf6f9f0ce86cb9396ed337a42
|
||||
version: aed02d124ae4a0e94fea4541c8effd05bf0c8296
|
||||
- name: github.com/hashicorp/consul
|
||||
version: 67a03d57b5851011e5601ee6e7e3d05699548462
|
||||
version: fce7d75609a04eeb9d4bf41c8dc592aac18fc97d
|
||||
subpackages:
|
||||
- api
|
||||
- name: github.com/hashicorp/go-cleanhttp
|
||||
version: ad28ea4487f05916463e2423a55166280e8254b5
|
||||
version: 875fb671b3ddc66f8e2f0acc33829c8cb989a38d
|
||||
- name: github.com/hashicorp/serf
|
||||
version: 555e0dcbb180ecbd03431adc28226bb3192558bc
|
||||
version: 6c4672d66fc6312ddde18399262943e21175d831
|
||||
subpackages:
|
||||
- coordinate
|
||||
- serf
|
||||
- name: github.com/jarcoal/httpmock
|
||||
version: 145b10d659265440f062c31ea15326166bae56ee
|
||||
- name: github.com/libkermit/compose
|
||||
|
@ -193,74 +194,74 @@ imports:
|
|||
- name: github.com/mattn/go-shellwords
|
||||
version: 525bedee691b5a8df547cb5cf9f86b7fb1883e24
|
||||
- name: github.com/mesos/mesos-go
|
||||
version: 2b28dad0aa75289407717b98d82c7871543bb4db
|
||||
version: 068d5470506e3780189fe607af40892814197c5e
|
||||
subpackages:
|
||||
- mesosproto
|
||||
- mesos
|
||||
- upid
|
||||
- mesosutil
|
||||
- detector
|
||||
- detector/zoo
|
||||
- mesos
|
||||
- mesosproto
|
||||
- mesosutil
|
||||
- upid
|
||||
- name: github.com/mesosphere/mesos-dns
|
||||
version: b47dc4c19f215e98da687b15b4c64e70f629bea5
|
||||
repo: https://github.com/containous/mesos-dns.git
|
||||
vcs: git
|
||||
subpackages:
|
||||
- detect
|
||||
- errorutil
|
||||
- logging
|
||||
- models
|
||||
- records
|
||||
- records/labels
|
||||
- records/state
|
||||
- util
|
||||
- errorutil
|
||||
- models
|
||||
- records/labels
|
||||
- name: github.com/Microsoft/go-winio
|
||||
version: ce2922f643c8fd76b46cadc7f404a06282678b34
|
||||
- name: github.com/miekg/dns
|
||||
version: 5d001d020961ae1c184f9f8152fdc73810481677
|
||||
- name: github.com/mitchellh/mapstructure
|
||||
version: ca63d7c062ee3c9f34db231e352b60012b4fd0c1
|
||||
version: 21a35fb16463dfb7c8eee579c65d995d95e64d1e
|
||||
- name: github.com/moul/http2curl
|
||||
version: b1479103caacaa39319f75e7f57fc545287fca0d
|
||||
- name: github.com/ogier/pflag
|
||||
version: 45c278ab3607870051a2ea9040bb85fcb8557481
|
||||
- name: github.com/opencontainers/runc
|
||||
version: 38e0df9ec67c05e73b656c02c9222f24c1683d73
|
||||
version: ff88baa42fa5b2a1568a3a14665142fb4bdb3a2a
|
||||
subpackages:
|
||||
- libcontainer/user
|
||||
- name: github.com/parnurzeal/gorequest
|
||||
version: 29ced6f360a5ac3823a3675b4e29fbab336cc186
|
||||
version: 045012d33ef41ea146c1b675df9296d0dc1a212d
|
||||
- name: github.com/pmezard/go-difflib
|
||||
version: 792786c7400a136282c1664665ae0a8db921c6c2
|
||||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
|
||||
subpackages:
|
||||
- difflib
|
||||
- name: github.com/ryanuber/go-glob
|
||||
version: 572520ed46dbddaed19ea3d9541bdd0494163693
|
||||
- name: github.com/samuel/go-zookeeper
|
||||
version: 87e1bca4477a3cc767ca71be023ced183d74e538
|
||||
version: e64db453f3512cade908163702045e0f31137843
|
||||
subpackages:
|
||||
- zk
|
||||
- name: github.com/Sirupsen/logrus
|
||||
version: 3ec0642a7fb6488f65b06f9040adc67e3990296a
|
||||
version: a283a10442df8dc09befd873fab202bf8a253d6a
|
||||
- name: github.com/streamrail/concurrent-map
|
||||
version: 8bf1e9bacbf65b10c81d0f4314cf2b1ebef728b5
|
||||
version: 65a174a3a4188c0b7099acbc6cfa0c53628d3287
|
||||
- name: github.com/stretchr/objx
|
||||
version: 1a9d0bb9f541897e62256577b352fdbc1fb4fd94
|
||||
version: cbeaeb16a013161a98496fad62933b1d21786672
|
||||
- name: github.com/stretchr/testify
|
||||
version: d77da356e56a7428ad25149ca77381849a6a5232
|
||||
subpackages:
|
||||
- assert
|
||||
- mock
|
||||
- assert
|
||||
- name: github.com/thoas/stats
|
||||
version: 152b5d051953fdb6e45f14b6826962aadc032324
|
||||
version: 79b768ff1780f4e5b0ed132e192bfeefe9f85a9c
|
||||
- name: github.com/tv42/zbase32
|
||||
version: 501572607d0273fc75b3b261fa4904d63f6ffa0e
|
||||
version: 03389da7e0bf9844767f82690f4d68fc097a1306
|
||||
- name: github.com/ugorji/go
|
||||
version: 98ef79d6c615fa258e892ed0b11c6e013712693e
|
||||
version: b94837a2404ab90efe9289e77a70694c355739cb
|
||||
subpackages:
|
||||
- codec
|
||||
- name: github.com/unrolled/render
|
||||
version: 3f4913244021dede105b62caecfb01f0c1eebeda
|
||||
version: 198ad4d8b8a4612176b804ca10555b222a086b40
|
||||
- name: github.com/vdemeester/docker-events
|
||||
version: be74d4929ec1ad118df54349fda4b0cba60f849b
|
||||
- name: github.com/vdemeester/shakers
|
||||
|
@ -273,51 +274,50 @@ imports:
|
|||
- cbreaker
|
||||
- connlimit
|
||||
- forward
|
||||
- memmetrics
|
||||
- roundrobin
|
||||
- stream
|
||||
- utils
|
||||
- memmetrics
|
||||
- name: github.com/vulcand/predicate
|
||||
version: 19b9dde14240d94c804ae5736ad0e1de10bf8fe6
|
||||
- name: github.com/vulcand/route
|
||||
version: 61904570391bdf22252f8e376b49a57593d9124c
|
||||
version: cb89d787ddbb1c5849a7ac9f79004c1fd12a4a32
|
||||
- name: github.com/vulcand/vulcand
|
||||
version: 7b479b160401beccbc9521b922588fa2a64c4818
|
||||
version: 28a4e5c0892167589737b95ceecbcef00295be50
|
||||
subpackages:
|
||||
- conntracker
|
||||
- plugin
|
||||
- plugin/rewrite
|
||||
- plugin
|
||||
- conntracker
|
||||
- router
|
||||
- name: github.com/xenolf/lego
|
||||
version: b2fad6198110326662e9e356a97199078a4a775c
|
||||
subpackages:
|
||||
- acme
|
||||
- name: golang.org/x/crypto
|
||||
version: 81372b2fc2f10bef2a7f338da115c315a56b2726
|
||||
version: d81fdb778bf2c40a91b24519d60cdc5767318829
|
||||
subpackages:
|
||||
- ocsp
|
||||
- bcrypt
|
||||
- blowfish
|
||||
- ocsp
|
||||
- name: golang.org/x/net
|
||||
version: 71a035914f99bb58fe82eac0f1289f10963d876c
|
||||
version: b400c2eff1badec7022a8c8f5bea058b6315eed7
|
||||
subpackages:
|
||||
- context
|
||||
- proxy
|
||||
- publicsuffix
|
||||
- proxy
|
||||
- name: golang.org/x/sys
|
||||
version: 8f0908ab3b2457e2e15403d3697c9ef5cb4b57a9
|
||||
version: 62bee037599929a6e9146f29d10dd5208c43507d
|
||||
subpackages:
|
||||
- unix
|
||||
- windows
|
||||
- name: gopkg.in/fsnotify.v1
|
||||
version: a8a77c9133d2d6fd8334f3260d06f60e8d80a5fb
|
||||
- name: gopkg.in/mgo.v2
|
||||
version: 3f83fa5005286a7fe593b055f0d7771a7dce4655
|
||||
version: 29cc868a5ca65f401ff318143f9408d02f4799cc
|
||||
subpackages:
|
||||
- bson
|
||||
- internal/json
|
||||
- name: gopkg.in/square/go-jose.v1
|
||||
version: 139276ceb5afbf13e636c44e9382f0ca75c12ba3
|
||||
version: e3f973b66b91445ec816dd7411ad1b6495a5a2fc
|
||||
subpackages:
|
||||
- cipher
|
||||
- json
|
||||
|
@ -331,17 +331,17 @@ testImports:
|
|||
- name: github.com/flynn/go-shlex
|
||||
version: 3f9db97f856818214da2e1057f8ad84803971cff
|
||||
- name: github.com/gorilla/mux
|
||||
version: 0a192a193177452756c362c20087ddafcf6829c4
|
||||
version: 9fa818a44c2bf1396a17f9d5a3c0f6dd39d2ff8e
|
||||
- name: github.com/libkermit/docker-check
|
||||
version: cbe0ef03b3d23070eac4d00ba8828f2cc7f7e5a3
|
||||
- name: github.com/spf13/pflag
|
||||
version: c7e63cf4530bcd3ba943729cee0efeff2ebea63f
|
||||
version: 5644820622454e71517561946e3d94b9f9db6842
|
||||
- name: github.com/vbatts/tar-split
|
||||
version: 6810cedb21b2c3d0b9bb8f9af12ff2dc7a2f14df
|
||||
subpackages:
|
||||
- archive/tar
|
||||
- tar/asm
|
||||
- tar/storage
|
||||
- archive/tar
|
||||
- name: github.com/xeipuuv/gojsonpointer
|
||||
version: e0fe6f68307607d540ed8eac07a342c33fa1b54a
|
||||
- name: github.com/xeipuuv/gojsonreference
|
||||
|
|
|
@ -35,6 +35,7 @@ type Docker struct {
|
|||
Domain string `description:"Default domain used"`
|
||||
TLS *ClientTLS `description:"Enable Docker TLS support"`
|
||||
ExposedByDefault bool `description:"Expose containers by default"`
|
||||
UseBindPortIP bool `description:"Use the ip address from the bound port, rather than from the inner network"`
|
||||
}
|
||||
|
||||
func (provider *Docker) createClient() (client.APIClient, error) {
|
||||
|
@ -173,7 +174,7 @@ func (provider *Docker) loadDockerConfig(containersInspected []dockertypes.Conta
|
|||
|
||||
// filter containers
|
||||
filteredContainers := fun.Filter(func(container dockertypes.ContainerJSON) bool {
|
||||
return provider.containerFilter(container, provider.ExposedByDefault)
|
||||
return provider.containerFilter(container)
|
||||
}, containersInspected).([]dockertypes.ContainerJSON)
|
||||
|
||||
frontends := map[string][]dockertypes.ContainerJSON{}
|
||||
|
@ -256,7 +257,7 @@ func (provider *Docker) getMaxConnExtractorFunc(container dockertypes.ContainerJ
|
|||
return "request.host"
|
||||
}
|
||||
|
||||
func (provider *Docker) containerFilter(container dockertypes.ContainerJSON, exposedByDefaultFlag bool) bool {
|
||||
func (provider *Docker) containerFilter(container dockertypes.ContainerJSON) bool {
|
||||
_, err := strconv.Atoi(container.Config.Labels["traefik.port"])
|
||||
if len(container.NetworkSettings.Ports) == 0 && err != nil {
|
||||
log.Debugf("Filtering container without port and no traefik.port label %s", container.Name)
|
||||
|
@ -267,7 +268,7 @@ func (provider *Docker) containerFilter(container dockertypes.ContainerJSON, exp
|
|||
return false
|
||||
}
|
||||
|
||||
if !isContainerEnabled(container, exposedByDefaultFlag) {
|
||||
if !isContainerEnabled(container, provider.ExposedByDefault) {
|
||||
log.Debugf("Filtering disabled container %s", container.Name)
|
||||
return false
|
||||
}
|
||||
|
@ -321,6 +322,17 @@ func (provider *Docker) getIPAddress(container dockertypes.ContainerJSON) string
|
|||
return "127.0.0.1"
|
||||
}
|
||||
|
||||
if provider.UseBindPortIP {
|
||||
port := provider.getPort(container)
|
||||
for netport, portBindings := range container.NetworkSettings.Ports {
|
||||
if string(netport) == port+"/TCP" || string(netport) == port+"/UDP" {
|
||||
for _, p := range portBindings {
|
||||
return p.HostIP
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, network := range container.NetworkSettings.Networks {
|
||||
return network.IPAddress
|
||||
}
|
||||
|
|
|
@ -865,7 +865,8 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, e := range containers {
|
||||
actual := provider.containerFilter(e.container, e.exposedByDefault)
|
||||
provider.ExposedByDefault = e.exposedByDefault
|
||||
actual := provider.containerFilter(e.container)
|
||||
if actual != e.expected {
|
||||
t.Fatalf("expected %v for %+v, got %+v", e.expected, e, actual)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue