feat: bind to 127.0.0.1 by default instead of 0.0.0.0#2812
Open
feat: bind to 127.0.0.1 by default instead of 0.0.0.0#2812
Conversation
Port bindings now default to localhost-only, preventing prediction endpoints from being exposed to the entire network during development. - Add HostIP field to command.Port struct (defaults to 127.0.0.1) - Add --host flag to cog serve (default 127.0.0.1, use 0.0.0.0 to expose) - Support host:port syntax in cog run -p (e.g. -p 0.0.0.0:8888) - Bind cog predict/train to 127.0.0.1 - Update GetHostPortForContainer to match configured host IP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
0.0.0.0to127.0.0.1across all commands, preventing prediction endpoints from being accidentally exposed to the entire network during development.--hostflag tocog serveandhost:portsyntax tocog run -pso users can opt into binding to all interfaces when needed.Changes
pkg/docker/command/command.goHostIPfield toPortstructpkg/docker/docker.goport.HostIP(default127.0.0.1) instead of hardcoded""pkg/docker/run.goGetHostPortForContainernow accepts ahostIPparameterpkg/docker/run_test.gopkg/cli/serve.go--hostflag (default127.0.0.1)pkg/cli/run.go-pflag supportshost:portsyntax (e.g.-p 0.0.0.0:8888), defaults to127.0.0.1pkg/predict/predictor.gocog predict/cog trainbind to127.0.0.1User-facing behavior
cog serve0.0.0.0127.0.0.1. Use--host 0.0.0.0to expose.cog run -p 88880.0.0.0:8888127.0.0.1:8888. Use-p 0.0.0.0:8888to expose.cog predict/cog train0.0.0.0127.0.0.1Test plan