PSA: Selfhosting? Beware of open ports on the internet! #587
-
If you have all the steps given in the readme, there will be 3 ports exposed over the internet: 7777 (sl-app), 20381 (sl-email) & 5432 (postgresql). You can verify the ports are open by running the following command from a different machine. sudo nmap -sS <IP-ADDR> -p 7777,20381,5432 It is important to secure the Postgres port. Using To get around this, first run this command to allow only localhost connections to the docker containers: iptables -I DOCKER-USER -i eth0 ! -s 127.0.0.1 -j DROP Docker documentation reference for more info: documentation. Next, to make the changes persistent across reboots, we are going to use sudo apt install iptables-persistent
sudo service netfilter-persistent save Reboot your machine and run the above I have submitted a PR to add this info in the main readme file. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
@prashantkamdar thanks for the suggestion. I think binding to |
Beta Was this translation helpful? Give feedback.
-
Yes, this seems like a good solution. Reason: you will have to delete the existing sl-db container and recreate it with the above params. |
Beta Was this translation helpful? Give feedback.
-
I feel stupid for having missed the mounted volume of the database. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the merge! |
Beta Was this translation helpful? Give feedback.
@prashantkamdar thanks for the suggestion. I think binding to
127.0.0.1
should be enough to avoid the container being accessible to the public. For example instead of using-p 7777:7777
, we can use-p 127.0.0.1:7777:77
instead. What do you think?