Im a little confused about firewalld and I am trying to secure docker containers by using docker-compose to force the container to listen only on localhost:
docker-compose ps
Name Command State Ports
--------------------------------------------------------------------------------------
srv_postgres-srv_1 /docker-entrypoint.sh postgres Up 127.0.0.1:5432->5432/tcp
services:
postgres-srv:
image: postgres:9.5.5
volumes:
- postgres-srv_volume:/var/lib/postgresql/data
ports:
- "127.0.0.1:5432:5432"
volumes:
postgres-srv_volume:
But when I try to use firewalld to forward external traffic to it, connections are refused. My firewalld configuration so far:
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports:
protocols:
masquerade: yes
forward-ports: port=5432:proto=tcp:toport=5432:toaddr=127.0.0.1
source-ports:
icmp-blocks:
rich rules:
rule family="ipv4" source address="192.168.1.1/32" port port="5432" protocol="tcp" accept
Please what am I doing wrong?