Skip to content
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
9 changes: 5 additions & 4 deletions containers/squid/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
FROM ubuntu/squid:latest

# Install additional tools for debugging, healthcheck, and SSL Bump
# gosu is used to drop from root to proxy user after permission setup
# Retry logic handles transient 404s when Ubuntu archive supersedes package versions mid-build
RUN set -eux; \
PKGS="curl dnsutils net-tools netcat-openbsd openssl squid-openssl"; \
PKGS="curl dnsutils gosu net-tools netcat-openbsd openssl squid-openssl"; \
apt-get update && \
apt-get install -y --only-upgrade gpgv && \
( apt-get install -y --no-install-recommends $PKGS || \
(rm -rf /var/lib/apt/lists/* && apt-get update && \
apt-get install -y --no-install-recommends $PKGS) ) && \
rm -rf /var/lib/apt/lists/*

# Create log directory and SSL database directory
RUN mkdir -p /var/log/squid && \
chown -R proxy:proxy /var/log/squid
# Create log directory and SSL database directory, ensure proxy user owns them
RUN mkdir -p /var/log/squid /var/spool/squid /var/run/squid && \
chown -R proxy:proxy /var/log/squid /var/spool/squid /var/run/squid /etc/squid

# Copy entrypoint script
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
Expand Down
10 changes: 8 additions & 2 deletions containers/squid/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,11 @@ if [ -d "/var/spool/squid_ssl_db" ]; then
echo "[squid-entrypoint] SSL certificate database ready"
fi

# Start Squid
exec squid -N -d 1
# Ensure Squid config directory and run directory are writable by proxy
chown -R proxy:proxy /etc/squid /var/run/squid /var/spool/squid 2>/dev/null || true

# Ensure pid file is writable by proxy user (default: /run/squid.pid)
touch /run/squid.pid && chown proxy:proxy /run/squid.pid

# Drop to proxy user and start Squid
exec gosu proxy squid -N -d 1
4 changes: 2 additions & 2 deletions src/docker-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2008,11 +2008,11 @@ describe('docker-manager', () => {
// May fail after writing configs
}

// Verify squid.conf has restricted permissions
// Verify squid.conf is readable by proxy user (0o644) for non-root Squid
const squidConfPath = path.join(testDir, 'squid.conf');
if (fs.existsSync(squidConfPath)) {
const stats = fs.statSync(squidConfPath);
expect((stats.mode & 0o777).toString(8)).toBe('600');
expect((stats.mode & 0o777).toString(8)).toBe('644');
}

// Verify docker-compose.yml has restricted permissions
Expand Down
2 changes: 1 addition & 1 deletion src/docker-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ export async function writeConfigs(config: WrapperConfig): Promise<void> {
allowHostPorts: config.allowHostPorts,
});
const squidConfigPath = path.join(config.workDir, 'squid.conf');
fs.writeFileSync(squidConfigPath, squidConfig, { mode: 0o600 });
fs.writeFileSync(squidConfigPath, squidConfig, { mode: 0o644 });
logger.debug(`Squid config written to: ${squidConfigPath}`);

// Write Docker Compose config
Expand Down
Loading