mirror of
https://github.com/umputun/reproxy.git
synced 2024-11-23 17:51:32 +03:00
support reproxy.enabled label, enforce this label for reproxy container itself #16
This commit is contained in:
parent
825a3c3c7f
commit
9462170cd1
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@
|
||||
access.log
|
||||
var/
|
||||
dist/
|
||||
docker-compose-private.yml
|
@ -21,7 +21,7 @@ FROM umputun/baseimage:app-latest
|
||||
|
||||
COPY --from=backend /build/reproxy /srv/reproxy
|
||||
RUN chmod +x /srv/reproxy
|
||||
|
||||
LABEL reproxy.enabled="false"
|
||||
WORKDIR /srv
|
||||
|
||||
CMD ["/srv/reproxy"]
|
||||
|
@ -68,10 +68,11 @@ This default can be changed with labels:
|
||||
- `reproxy.dest` - destination path. Note: this is not full url, but just the path which will be appended to container's ip:port
|
||||
- `reproxy.ping` - ping path for the destination container.
|
||||
|
||||
By default all containers with exposed port will be considered as routing destinations. There are 2 ways to restrict it:
|
||||
By default all containers with exposed port will be considered as routing destinations. There are 3 ways to restrict it:
|
||||
|
||||
- Exclude some containers explicitly with `--docker.exclude`, i.e. `--docker.exclude=c1 --docker.exclude=c2 ...`
|
||||
- Allow only a particular docker network with `--docker.network`
|
||||
- Set the label `reproxy.enabled=false` or `reproxy.enabled=no`
|
||||
|
||||
This is a dynamic provider and any change in container's status will be applied automatically.
|
||||
|
||||
|
@ -162,6 +162,13 @@ func (d *Docker) listContainers() (res []containerInfo, err error) {
|
||||
continue
|
||||
}
|
||||
|
||||
if v, ok := c.Labels["reproxy.enabled"]; ok {
|
||||
if strings.EqualFold(v, "false") || strings.EqualFold(v, "no") {
|
||||
log.Printf("[DEBUG] skip container %s due to reproxy.enabled=%s", containerName, v)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
var ip string
|
||||
for k, v := range c.Networks.Networks {
|
||||
if d.Network == "" || k == d.Network { // match on network name if defined
|
||||
|
@ -41,6 +41,15 @@ func TestDocker_List(t *testing.T) {
|
||||
{PrivatePort: 12345},
|
||||
},
|
||||
},
|
||||
{Names: []string{"c5"}, State: "running",
|
||||
Networks: dc.NetworkList{
|
||||
Networks: map[string]dc.ContainerNetwork{"bridge": {IPAddress: "127.0.0.122"}},
|
||||
},
|
||||
Ports: []dc.APIPort{
|
||||
{PrivatePort: 2345},
|
||||
},
|
||||
Labels: map[string]string{"reproxy.enabled": "false"},
|
||||
},
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user