大网数据广告活动
服务器运维问答

Running docker containers only local behind csf firewall

· 52CE 我爱测

I want to access docker containers only locally behind the csf firewall on a remote Ubuntu server. I changed the DOCKER settings options in /etc/csf/csf.conf to 1 to allow docker to change iptable rules. If I am starting my conta…

问题原文

原帖链接 · mhellmeier · CC BY-SA 4.0

I want to access docker containers only locally behind the csf firewall on a remote Ubuntu server. I changed the DOCKER settings options in /etc/csf/csf.conf to 1 to allow docker to change iptable rules.

If I am starting my container with -p 8000:8000, the port 8000 is exposed to the whole world (I can access the website with mydomain.com:8000, as expected, but not what I wanted). If I am starting the container with -p 127.0.0.1:8000:8000 I can't access it with mydomain.com:8000 (which is great), but in both cases calling localhost:8000 will result in an ERR_EMPTY_RESPONSE error in Chrome or curl: (52) Empty reply from server in the terminal.

Tried it with different containers and different ports. After disabling csf, it works without the empty-reply-error so is must be related to csf.

How to configure csf to expose and access docker container over specific ports only locally?

Sidenote: I am working remotely on the server with ssh [email omitted] -L 8000:localhost:8000.

社区高分解答

原帖链接 · TheBalanceOfEvidence · CC BY-SA 4.0

Had the same scenario. Found that packets from lo to docker0 were being blocked by CSF's OUTPUT ruleset.

Resolved by adding "docker0" to ETH_DEVICE_SKIP, which causes CSF to add a blanket ACCEPT rule to the INPUT and OUTPUT chains for this interface. This should not be a problem since AFAIK docker0 should never be bound to a physical interface, but someone with more Docker experience might know otherwise.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-06-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。