Skip to content

Commit

Permalink
Add bind flag for specifying address to bind to
Browse files Browse the repository at this point in the history
  • Loading branch information
jthomperoo committed Jul 15, 2024
1 parent ee07c0a commit e292f58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- New `--bind` option which allows you to specify what address to bind to, defaults to `0.0.0.0`.

## [v1.1.1] - 2023-12-04
### Fixed
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ Usage of simple-proxy:
log to standard error as well as files
-basic-auth string
basic auth, format 'username:password', no auth if not provided
-bind string
address to bind the proxy server to (default "0.0.0.0")
-cert string
path to cert file
-key string
Expand Down Expand Up @@ -112,7 +114,7 @@ and port.
On Windows you can use:
```powershell
curl.exe 'https://www.random.org/integers/?num=1&min=1&max=5&col=1&base=10&format=plain&rnd=new' --proxy 'http://localhost:8888'
curl.exe --proxy 'http://localhost:8888' 'https://www.random.org/integers/?num=1&min=1&max=5&col=1&base=10&format=plain&rnd=new'
```
## Contributing
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func main() {
flag.BoolVar(&version, "version", false, "prints current simple-proxy version")
var protocol string
flag.StringVar(&protocol, "protocol", httpProtocol, "proxy protocol (http or https)")
var bind string
flag.StringVar(&bind, "bind", "0.0.0.0", "address to bind the proxy server to")
var port string
flag.StringVar(&port, "port", "8888", "proxy port to listen on")
var certPath string
Expand Down Expand Up @@ -83,7 +85,7 @@ func main() {
}

server := &http.Server{
Addr: fmt.Sprintf(":%s", port),
Addr: fmt.Sprintf("%s:%s", bind, port),
Handler: handler,
// Disable HTTP/2.
TLSNextProto: make(map[string]func(*http.Server, *tls.Conn, http.Handler)),
Expand Down

0 comments on commit e292f58

Please sign in to comment.