Skip to content

Commit b47fbe6

Browse files
authored
Deny acces from outer world
1 parent 0f9fc63 commit b47fbe6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,40 @@ Now you are ready to go with a little CI/CD Environment:
3535
```
3636
#### Security
3737
... not really, its all http .. don't worry about it! It's only local communication
38+
<span style="color:red">WARNING</span>
39+
All the Services are reachable because docker creates and deletes dynamically FORWARD Rules with ACCEPT on startup / shutdown containers with exported ports.
40+
To deny acccess froum outer world the DOCKER-USER Chain (since docker 17.06) ist the medium of choice.
41+
A little Script to deny all access from outer world to your local build environment could be
42+
```
43+
#!/bin/bash
44+
if [ $# -lt 1 ] ; then
45+
echo "Need your external interface as one parameter"
46+
echo "Common names are eth0, enp...,"
47+
echo "List of your names"
48+
ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'
49+
exit
50+
fi
51+
52+
PORTS_TO_BLOCK="80,5555,2222"
53+
EXTERNAL_INTERFACE=$1
54+
55+
iptables -F DOCKER-USER
56+
iptables -F EXTERNAL-ACCESS-DENY
57+
iptables -X EXTERNAL-ACCESS-DENY
58+
59+
iptables -N EXTERNAL-ACCESS-DENY
60+
iptables -A EXTERNAL-ACCESS-DENY -j LOG --log-prefix "DCKR-EXT-ACCESS-DENY:" --log-level 6
61+
iptables -A EXTERNAL-ACCESS-DENY -j DROP
62+
63+
iptables -A DOCKER-USER -i $EXTERNAL_INTERFACE -p tcp --match multiport --dports $PORTS_TO_BLOCK -j EXTERNAL-ACCESS-DENY
64+
iptables -A DOCKER-USER -j RETURN
65+
66+
echo "Rules created "
67+
iptables -v -L DOCKER-USER
68+
iptables -v -L EXTERNAL-ACCESS-DENY
69+
echo "See logs with prefix DCKR-EXT-ACCESS-DENY:"
70+
```
71+
3872

3973
### Logins and Passwords
4074

0 commit comments

Comments
 (0)