-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I cannot get bouncer to deny http/https connection with Docker but blocking ping works #312
Comments
Could you provide the output of |
Output of '# Warning: iptables-legacy tables present, use iptables-legacy to see them Chain FORWARD (policy DROP) Chain OUTPUT (policy ACCEPT) Chain DOCKER (2 references) Chain DOCKER-ISOLATION-STAGE-1 (1 references) Chain DOCKER-ISOLATION-STAGE-2 (2 references) Chain DOCKER-USER (1 references) |
So everything that I expect to see within the chains is there. However, you might want to investigate |
I think you are right. While I was waiting for you to reply before, I put in IPTable rules to deny traffic using the same IP list Crowdsec does on every chain but didn't do it on the legacy ones mostly because I didn't make that connection. So with a rule on all the chains I sent you before, I was still able to hit the web page. So it must be using the legacy tables or something. I was thinking that the IP tables are like firewall rules and the first one takes priority, my mistake was assuming that the legacy ones are called from the non-legacy ones. I will update you as soon as I know more. Thanks for all you help so far. Just the point in the IPtable direction has been a huge leap because I didn't know that was the mechanism blocking. |
Ok so now I have tried a couple things and still cannot get it to work but have more information.... I removed all of the legacy IP tables and disabled their creation so that I could enable the bouncer. With the legacy ones removed, I still cannot get it to work correctly. The webpage is denied (as expected) if I hit the server with the IP:Port. Where I am having trouble is that when I try to load the webpage using the FQDN, through my reverse proxy, the webpage is not denied. I am going to try some additional tests like setting up the bouncer to deny access on port 25 or 465 but that might take me a little to setup. If you have any ideas or think I should try something else, any help is appreciated. |
To be honest, I got nothing more to add. The bouncers is doing what it suppose to do and injecting the rules to the top of the chains. Remember to constantly check |
OK I got it working. Thanks again to @LaurenceJJones for pointing me in the right direction. Your help allowed me to at least know what services to google to take deeper dives. There were several areas that needed to be modified on my part. I am documenting this all so that if anyone runs into a similar issue, maybe they can use my lessons learned to help. First, the reason that I was still able to hit the webpage was that the mail server was behind a reverse proxy. I looked into how the data was being sent to the mailcow server by enabling logging on IPTABLES. When I looked at the data, it appears that the proxy server was making the HTTP requests. When an IP was banned, I needed it to be banned on the proxy server AND the mail server. It needs to be banned on both because I have all port 80 and 443 traffic port forwarded in my router to the proxy server but the SMTPS(465),POP(995)... all the ports for mail server stuff are forwarded to the mail server directly. There is a tutorial an setting up crowdsec with multiple servers How to set up a CrowdSec multi-server installation and CrowdSec Multiserver Docker. This issue being that I needed both since my proxy server is Ngnix Proxy Manager running in docker. That configuration did not expose the bouncer port (8080) so I had two modify the docker-compose file. The part :
was really important as without it the 'mothership' (or server 2&3) would not receive heartbeats from the mail server. fail2ban is automatically enabled on Mailcow. I had to modify the configuration so that it would not ban an IP before Crowdsec was able to. Again, the vision being that banned IP addresses be banned everywhere. lastly, once I get everything working. I ran into an issue where a blocked IP would not be blocked by the individual machine but would be blocked by all the other machines- through the Proxy server. I took a look at the Bouncer logs and found an error "time="19-08-2023 14:56:04" level=info msg="Error while inserting in set (/usr/sbin/ipset -exist add crowdsec-blacklists 116.212.142.42 timeout 583196): exit status 1 --> ipset v7.15: Hash is full, cannot add more elements\n" this is already an identified issue #260. After I made the change, everything completely worked. |
As the title suggests, I have crowdsec-firewall-bouncer setup and it appears to be working. When I ping the machine it does appear to be blocked but when I navigate to a hosted webpage I am still able to connect. I believe the issue is with the connection to Docker. The full setup I have is MailCow running in Docker. I followed the instructions at Protecting Mailcow with Crowdsec and went a little further than the instructions by modifying the bouncer config to include the forward and docker-user chains. Any help in troubleshooting would be great!
crowdsec-firewall-bouncer.yaml (I had to put the ticks so it was formatted correctly)
crowdsec-firewall-bouncer.log
The text was updated successfully, but these errors were encountered: