Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind credential listener to localhost #1105

Merged
merged 2 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions agent/config/config_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
)

const (
// AgentCredentialsAddress is used to serve the credentials for tasks.
AgentCredentialsAddress = "" // this is left blank right now for net=bridge
// defaultAuditLogFile specifies the default audit log filename
defaultCredentialsAuditLogFile = "/log/audit.log"
// Default cgroup prefix for ECS tasks
Expand Down
3 changes: 3 additions & 0 deletions agent/config/config_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import (
)

const (
// AgentCredentialsAddress is used to serve the credentials for tasks.
AgentCredentialsAddress = "127.0.0.1"
// defaultAuditLogFile specifies the default audit log filename
defaultCredentialsAuditLogFile = `log\audit.log`
// When using IAM roles for tasks on Windows, the credential proxy consumes port 80
httpPort = 80
Expand Down
2 changes: 1 addition & 1 deletion agent/handlers/credentials/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func setupServer(credentialsManager credentials.Manager, auditLogger audit.Audit
loggingServeMux.Handle("/", handlers.NewLoggingHandler(serverMux))

server := http.Server{
Addr: ":" + strconv.Itoa(config.AgentCredentialsPort),
Addr: config.AgentCredentialsAddress + ":" + strconv.Itoa(config.AgentCredentialsPort),
Handler: loggingServeMux,
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
Expand Down
3 changes: 2 additions & 1 deletion misc/windows-deploy/hostsetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $ErrorActionPreference = 'Continue'
# 169.254.170.2:51679 is the IP address used for task IAM roles.
$credentialAddress = "169.254.170.2"
$credentialPort = "51679"
$loopbackAddress = "127.0.0.1"

$adapter = (Get-NetAdapter -Name "*APIPA*")
if(!($adapter)) {
Expand All @@ -45,7 +46,7 @@ if(!($ip)) {

# This forwards traffic from port 80 and listens on the IAM role IP address.
# 'portproxy' doesn't have a powershell module equivalent, but we could move if it becomes available.
netsh interface portproxy add v4tov4 listenaddress=$credentialAddress listenport=80 connectaddress=$credentialAddress connectport=$credentialPort
netsh interface portproxy add v4tov4 listenaddress=$credentialAddress listenport=80 connectaddress=$loopbackAddress connectport=$credentialPort
}

$ErrorActionPreference=$oldActionPref