@@ -63,3 +63,34 @@ func Test_dockerProxyServerPrefix(t *testing.T) {
6363 assert .Empty (t , g (store , fmt .Sprintf ("traefik/http/routers/%s/service" , "hello-detect2" )))
6464 assert .NotEmpty (t , g (store , fmt .Sprintf ("traefik/http/routers/%s/service" , "prefixed" )))
6565}
66+
67+ // test that services with kop.bind.ip or foo.kop.bind.ip labels are handled correctly
68+ func Test_dockerProxyServerPrefixWithKopBindIP (t * testing.T ) {
69+ mockDockerEndpoint := dockerEndpoint
70+ mockDockerClient := dc
71+
72+ // now create our proxy pointing to the mock
73+ proxyServer := createProxy (mockDockerClient , "foo" )
74+ _ , proxyDockerEndpoint := proxyServer .start ()
75+
76+ var err error
77+ dockerEndpoint = proxyDockerEndpoint
78+ dc , err = createDockerClient (proxyDockerEndpoint )
79+ assert .NoError (t , err , "should create docker client" )
80+ defer func () {
81+ dockerEndpoint = mockDockerEndpoint
82+ dc = mockDockerClient
83+ }()
84+
85+ // both services get mapped to the same port (error case)
86+ store := processFile (t , "hellodetect.yml" )
87+ processFileWithConfig (t , store , nil , "prefix-bindip.yml" )
88+
89+ assertServiceIPs (t , store , []svc {
90+ {"prefixed" , "http" , "http://foo.bar.baz:5588" },
91+ {"unprefixed" , "http" , "http://example.local:5599" },
92+ })
93+
94+ assert .Empty (t , g (store , fmt .Sprintf ("traefik/http/routers/%s/service" , "hello-detect2" )))
95+ assert .NotEmpty (t , g (store , fmt .Sprintf ("traefik/http/routers/%s/service" , "prefixed" )))
96+ }
0 commit comments