Skip to content

Commit

Permalink
Add allowed cidrs in agent configuration (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpaquet authored and evelynl94 committed Jul 18, 2019
1 parent 253c470 commit 9db5277
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions agent/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func Run(flags *Flags) {
}

log.Fatal(nginx.Run(config.Nginx, map[string]interface{}{
"allowed_cidrs": config.AllowedCidrs,
"port": flags.AgentRegistryPort,
"registry_server": nginx.GetServer(
config.Registry.Docker.HTTP.Net, config.Registry.Docker.HTTP.Addr),
Expand Down
1 change: 1 addition & 0 deletions agent/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ type Config struct {
RegistryBackup string `yaml:"registry_backup"`
Nginx nginx.Config `yaml:"nginx"`
TLS httputil.TLSConfig `yaml:"tls"`
AllowedCidrs []string `yaml:"allowed_cidrs"`
}
5 changes: 5 additions & 0 deletions config/agent/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ registry:

peer_id_factory: addr_hash

# Allow agent to only serve localhost and Docker default bridge requests.
allowed_cidrs:
- 127.0.0.1
- 172.17.0.1

nginx:
name: kraken-agent
cache_dir: /var/cache/kraken/kraken-agent/nginx/
Expand Down
6 changes: 3 additions & 3 deletions nginx/config/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ upstream registry-backend {
server {
listen {{.port}};
# Allow agent to only serve localhost and Docker default bridge requests.
allow 127.0.0.1;
allow 172.17.0.1;
{{range .allowed_cidrs}}
allow {{.}};
{{end}}
deny all;
{{.client_verification}}
Expand Down

0 comments on commit 9db5277

Please sign in to comment.