Skip to content

Commit b2bd3f9

Browse files
committed
feat: update proxy authentication handling to allow disabling with empty credentials
1 parent 67e82b6 commit b2bd3f9

5 files changed

Lines changed: 18 additions & 11 deletions

File tree

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
DOMAIN=example.com
33
EMAIL=you@example.com
44

5-
# Proxy credentials (override values in mounted config).
6-
PROXY_USERNAME=user
7-
PROXY_PASSWORD=pass
5+
# Proxy credentials (leave empty to disable Basic auth).
6+
PROXY_USERNAME=
7+
PROXY_PASSWORD=
88

99
# Optional: chain through an upstream proxy.
1010
# PROXY_UPSTREAM_PROXY=https://user:pass@upstream-proxy:8080

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,22 @@ Download the latest binary from the [Releases](https://github.com/hightemp/https
3030

3131
### Docker
3232

33-
One-liner (HTTP proxy on port 8080, default user/pass `user`/`pass`):
33+
One-liner (HTTP proxy on port 8080, **no authentication**):
3434

3535
```sh
3636
docker run -d --name https_proxy -p 8080:8080 hightemp/https_proxy:latest
3737
```
3838

39-
Override credentials via env vars (no config file needed):
39+
Enable Basic auth via env vars:
4040

4141
```sh
4242
docker run -d --name https_proxy -p 8080:8080 \
4343
-e PROXY_USERNAME=alice -e PROXY_PASSWORD=s3cret \
4444
hightemp/https_proxy:latest
4545
```
4646

47+
> If both `username` and `password` are empty, authentication is disabled.
48+
4749
With a custom config:
4850

4951
```sh

config.docker.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
proxy_addr: 0.0.0.0:8080
2-
username: user
3-
password: pass
2+
username: ""
3+
password: ""
44
proto: http
55
cert_path: ""
66
key_path: ""

docker-compose.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ services:
99
environment:
1010
PROXY_ADDR: 0.0.0.0:8080
1111
PROXY_PROTO: http
12-
PROXY_USERNAME: ${PROXY_USERNAME:-user}
13-
PROXY_PASSWORD: ${PROXY_PASSWORD:-pass}
12+
PROXY_USERNAME: ${PROXY_USERNAME:-}
13+
PROXY_PASSWORD: ${PROXY_PASSWORD:-}
1414
PROXY_UPSTREAM_PROXY: ${PROXY_UPSTREAM_PROXY:-}
1515

1616
# HTTPS proxy with Let's Encrypt certificates (read from shared volume)
@@ -23,8 +23,8 @@ services:
2323
environment:
2424
PROXY_ADDR: 0.0.0.0:8443
2525
PROXY_PROTO: https
26-
PROXY_USERNAME: ${PROXY_USERNAME:-user}
27-
PROXY_PASSWORD: ${PROXY_PASSWORD:-pass}
26+
PROXY_USERNAME: ${PROXY_USERNAME:-}
27+
PROXY_PASSWORD: ${PROXY_PASSWORD:-}
2828
PROXY_CERT_PATH: /etc/letsencrypt/live/${DOMAIN:?DOMAIN must be set in .env}/fullchain.pem
2929
PROXY_KEY_PATH: /etc/letsencrypt/live/${DOMAIN}/privkey.pem
3030
PROXY_UPSTREAM_PROXY: ${PROXY_UPSTREAM_PROXY:-}

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ func applyEnvOverrides(c *Config) {
210210
}
211211

212212
func basicAuth(w http.ResponseWriter, r *http.Request) bool {
213+
// Authentication disabled when no credentials are configured.
214+
if config.Username == "" && config.Password == "" {
215+
return true
216+
}
217+
213218
auth := r.Header.Get("Proxy-Authorization")
214219
if auth == "" {
215220
slog.Debug("No Proxy-Authorization header", "remote", r.RemoteAddr)

0 commit comments

Comments
 (0)