Commit 8c6047f
fix(squid): run Squid container as non-root user (#1153)
* fix(security): run Squid container as non-root user
Install gosu in the Squid container and use it to drop from root to the
proxy user (UID 13) before starting Squid. The entrypoint still runs as
root initially to fix mounted volume permissions, then drops privileges
via `gosu proxy` before exec'ing squid.
Changes:
- Dockerfile: install gosu, create and chown /var/spool/squid,
/var/run/squid, and /etc/squid for the proxy user
- entrypoint.sh: use `exec gosu proxy squid -N -d 1` instead of
`exec squid -N -d 1`
Fixes #250
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(squid): ensure /run/squid.pid is writable by proxy user
Squid's default pid_filename is /run/squid.pid, which is not writable
by the proxy user after dropping privileges via gosu. Create and chown
the pid file before starting Squid.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(squid): make squid.conf readable by proxy user
The squid.conf was written with mode 0o600 (owner-only), but since Squid
now runs as the proxy user via gosu, it couldn't read its own config file.
Changed to 0o644 so the proxy user can read it. The docker-compose.yml
retains 0o600 since it contains sensitive environment variables.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 65f71c5 commit 8c6047f
File tree
4 files changed
+16
-9
lines changed- containers/squid
- src
4 files changed
+16
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | | - | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2008 | 2008 | | |
2009 | 2009 | | |
2010 | 2010 | | |
2011 | | - | |
| 2011 | + | |
2012 | 2012 | | |
2013 | 2013 | | |
2014 | 2014 | | |
2015 | | - | |
| 2015 | + | |
2016 | 2016 | | |
2017 | 2017 | | |
2018 | 2018 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1254 | 1254 | | |
1255 | 1255 | | |
1256 | 1256 | | |
1257 | | - | |
| 1257 | + | |
1258 | 1258 | | |
1259 | 1259 | | |
1260 | 1260 | | |
| |||
0 commit comments