-
Notifications
You must be signed in to change notification settings - Fork 3k
Integration with crowdsecurity/cs-nginx-bouncer #1131
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
Comments
Referencing #39. |
I have read that feature request but, let me justify better my request. My requested integration ( https://hub.crowdsec.net/author/crowdsecurity/bouncers/cs-nginx-bouncer ) is already a lua script that works in OpenResty, so it would only be, in my opinion, a matter of copy-paste in the config file of NPM and not writing a new module or script to integrate it. Please allow me to cite from Crowdsec's website:
I understand that Crowdsec is a new tool for many but it is able to do even more than fail2ban and the learning curve is low and in the long run it would overtake f2b and all you have to do is configure it where to read the logs and it is already packed with detectors and ready to take action trough bouncers on new detected atacker or the ones downloaded from the community list. |
Yeah, it was not my intention to say this issue was the same thing as the fail2ban one, I just wanted to cross-link these issues, since this they seem mutually exclusive. |
I didn't thought you were saying that, just wanted to clarify a little bit since with appearance of crowdsec (v0.0.1 - May 15, 2020), supporting an old tool and reinventing the wheel and wasting time building around f2b seeamd like a bad idea. |
Hello, I'll add my vote for this feature. I thinks this is very different from fail2ban in which follows the crowdsourcing approach. Thanks! |
@Sparkxxx do you have the manual steps to do this for the time being? I'm not very familiar with crowdsec so forgive my naivete, I think I have setup crowdsec and metabse in the same dockerfile using the guide here and here, but when i test with nikto from another machine on the local network I do not see a new decision and logs don't appear to show traffic. There isn't an official docker image for the nginx bouncer either, but based on your comment it seems like there may not be a need for an extra bouncer container. Here's the setup I have so far:
|
I am head of community at CrowdSec (and an avid user myself). I think it's a great idea to add support for CrowdSec as well. Also I would like to offer my assistance and a way into the CrowdSec dev team if you need any help implementing it. I would also like to point any technical questions regarding CrowdSec to our discourse where all devs are available to help out. @nisargjoshi95 Did you ever get this working? If not, feel free to ask on the discourse :-) |
@nisargjoshi95 Did you ever get this working? If not, feel free to ask on the discourse :-) |
@Sparkxxx please give me a buzz on the discourse, on twitter @klausagnoletti or send me a mail [email protected]. I'd like to ask about your experience with CrowdSec etc. |
I am here to cast my vote, I haven't started looking in depth yet but does anyone have crowdsec setup with the bouncer and NPM? @klausagnoletti - Should I just go to the discourse and ask there or are there any crowdsec docs on how to set it all up while utilizing NPM? Thanks. |
@nisargjoshi95 I'll think your docker-compose wont work because nginx proxymanager is storing it's logs in other than the default nginx folders. change your acquis.yml to
|
@baudneo did this work for you? I would have thought there would be issues with NPM's custom log format. |
Sorry for my late reply. I don't get notifications from Github even though I enabled it :-/ Just go to the Discorse and ask. To my knowledge noone has tried integrating with npm yet. |
@jakern, it is a strange situation. If NPM is already running, proxying requests and I start up crowdsec with the newest config that @2Wanderer posted, everything is ok. When I reboot, NPM no longer will come up, citing an error binding to port :80 and :443 due to the crowdsec nginx bouncer using port :80 or :443. I am playing around trying to get things to mesh properly. Once I get that part stable I will start trying to integrated the logs structure. |
I tried creating a docker container extending the npm container and installing crowdsec-nginx-bouncer. It didn't work. Turns out npm doesn't use nginx but openresty, wghich we don't (yet) support. But it's on the roadmap. So I guess it'a a bit of a PITA to get working before then. |
Can you give a rough estimation when this will probably happen? |
No, it is not scheduled. Maybe the community will contribute it. It's open source after all :-) |
I already tried it with a custom dockerfile:
but I get some weird errors. here are some of these:
maybe you can help? or is this the error you mentioned, that not the real nginx but openresty is used? |
This is the error I mentioned. Openresty != nginx (and they're not compatible). So the .deb complains that dependencies are not installed. So it won't work, unfortunately. |
Anyways I have good news @leon1995. I asked the developers just to be sure. And it turns out they're working on it as we speak. Only a new bouncer is needed as logfiles are the same, apparently. I'll ping you here once it's out in some usable shape or form. Are you willing to do a beta test? |
@klausagnoletti I'm running on unRaid with NPM and willing to beta test if you need more people. I have to be honest: I have a pretty private server, so there won't be many visitors. I can imagine you'd rather have a beta tester with some spicey logs. |
Not gonna lie: That would be more interesting. But it won't prevent you to join the fun :-) |
@klausagnoletti I would also join the beta. However, mine is also a private server with multiple services and just a few people using it (maybe up to ten I think) |
So... @leon1995 and I will visit each other's servers like crazy til steam's coming out of our logs. Will that work for you, @klausagnoletti? 🤪 |
Sure, hit me up at klaus (at) crowdsec (dot) net. You'd have to do a Docker container on your own (but would be happy to help :-) |
I sent you an email |
I can help testing if you wish. I have a host with Dietpi for x86, several dockers containers, one with Nginx proxy manager, other with crowdsec with the logs from Nginx proxy manager logs mapped, and also the firewall bouncer installed on the host and connected to Crowdsec's docker container. |
Cool, please send me an email so I have your information in my inbox :-) |
Now there's interesting news! @dhernan3 @leon1995 @sanderdatema @baudneo @2Wanderer @nisargjoshi95 @Sparkxxx https://docs.crowdsec.net/docs/bouncers/openresty/ The bouncer is out. It should be easy to extend the existing npm Dockerfile with that since it's available as a .deb and npm is based on Debian. Let me know what comes out of experimenting with it :-) |
Will this also work with the CrowdSec agent installed directly on Docker host? |
Yes just edit the bouncer config file and put the ip:port of the docker host in the API_URL. Do not use "localhost:8080" use the actual IP for your docker host. If you have any issues when starting the container issue If you mean using docker networks I am not sure as I do not have my system setup that way. I am sure there is a way to make that work. I am currently building the multiarch image base images and will be pushing multi arch images soon. |
Thanks. I am using a Docker bridged network totally standardized. If one configures the agent to listen on 0.0.0.0 it can be reached from the container using it's docker network ip. Remember to firewall the port so it's not internet exposed (which reminds me that I asked the devs if there's a CrowdSec parser + scenario for CrowdSec. There should be. Very meta :-) |
I just ugrade my NPM with "baudneo/nginx-proxy-manager:cs-modsec" on my OpenWrt server (with NextCloud).
Back to the 'jc21/nginx-proxy-manager:latest' My own use for Nginx-Proxy-Manager is to check the logs externally from the dockerized side !
ad in the main OpenWrt host :
with intalled collection : |
@erdoukki - What's the CPU architecture for your OpenWRT server? |
architecture : aarch64 |
I don't see an ARM build for |
Good idea. |
I am trying with this "PR"... ;-) |
Working ! |
Thanks! Just tested;
but still issue :
|
Okay, just rebuild the docker and now works fine:
|
@baudneo Where can I submit issues for your fork? I have two:
Lastly I have a suggestion: Could you implement more environmental variables so everything in the bouncer configuration can configured like this. Especially the reCAPTCHA stuff.. Thanks - keep up the good work! |
Do I still have to add the log path to /etc/crowdsec/acquis.yaml here? |
Awesome! Thanks for updating it! |
Hello baudneo, thanks for this new image. I've tried to update, however docker can't pull the image, it complains about missing manifest. I've verified docker hub and think the image is not updated, is that ok?
|
Any chance this is being merged back into the base jc21/nginx-proxy-manager image ? |
ModSec is EoL now/soon and also has known memory leaks which are HUGE, so I won't be building images with it. I am currently working on ZoneMinder ML object detection stuff, as soon as I am done that I will create a new image with current NPM and add crowdsec openresty bouncer into it. I think the options for WAF are slim, coraza and open-appsec which I may or may not look into adding either of them into an NPM image. Coraza parses modsec security language, so the rules files like OWASP (who develop coraza as well) lists can be used with it. Furthermore, Coraza seems to need to be implemented in a Go language app. It is not as simple as download, point it at configs/rules and run it, someone needs to write a Go app using coraza libraries. That may have changed as I have not kept up with Coraza. open-appsec uses ML instead of signatures for threat detection which is neat but, I can't speak to its effectiveness. At the time when I realized ModSec had issues, open-appsec did not have a nginx connector, which I think they do now. They require you to have a cloud control panel of sorts, so IDK how feasible it is to integrate into NPM if you can't do a stand alone install. Again, things may have changed as I haven't kept up on open-appsec either. I stopped using NPM in favour of Cloudflare tunnels but, CF's new browser security check stuff is causing me grief so, I will need to move back to NPM. |
Is there any hope of this being revived? I would love to have the option of integrating Crowdsec with NPM. |
I have the following problem. When I want to login to npm and change the email as it asks me, the response is Forbidden. If I want to create a new user, I can't apply rights or change the password = Forbidden. I have a working npm instance which I temporarily shut down, Crowdesc installed with no errors. My concern is only on the change of email and password. Note : The correct permissions are applied to the folders in your fork. (I'm under unraid on Dell PowerEdge) |
Issue is now considered stale. If you want to keep it open, please comment 👍 |
👍 |
up news ? |
please integrate this into npm base image, shouldn't be hard to keep up and massive help for those using npm |
Hi! I'm trying without success to integrate the crowdsec with NPM in my docker setup? Paco |
There is a blog post how to set it up. https://www.crowdsec.net/blog/crowdsec-with-nginx-proxy-manager |
Is your feature request related to a problem? Please describe.
I would like to add protection for sites to NPM and be able to block IP's based on reputation/scenario using Crowdsecurity https://github.com/crowdsecurity which is a log analyzer and reactive firewall, something like fail2ban but in a much modern architecture and suitable for the containers world and having a distributed banlist generated from users around the world.
The question/feature request is how/where to add the https://github.com/crowdsecurity/cs-nginx-bouncer module to nginx config.
This bouncer leverages nginx lua's API, namely access_by_lua_file.
New/unknown IPs are checked against crowdsec API, and if request should be blocked, a 403 is returned to the user, and put in cache. The exact desired action can be configured in Crowdsec, like displaying captcas etc.
Describe the solution you'd like
I would like to have an easy way (example maybe) to deploy the bouncer without breaking things in npm.
Describe alternatives you've considered
None so far since it might take you minutes to offer a solution and it would take me hours to tweak things and break them :)
Additional context
Please have a look at https://crowdsec.net/ to understand what is crowdsec and how it works.
I use jc21/nginx-proxy-manager:latest for NPM and https://github.com/crowdsecurity/crowdsec/tree/master/docker for Crowdsec containers analyzing the nginx logs allready written by NPM on disk (docker map volumes ./npm_data/logs/:/var/log/nginx/ and have a quick look at acquis.yaml which tells crowdsec which logs to parse, mine looks like this):
`filenames:
labels:
type: nginx`
Thank you and hope you'd consider this as a valuable addition to NPM
The text was updated successfully, but these errors were encountered: