# Secure Nginx Proxy Manager Docker Instance with Crowdsec?

**URL:** <https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125>\
**Category:** Uncategorized\
**Created:** [November 6, 2024, 6:55pm UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125 "2024-11-06T18:55:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfgsdgsdgsd](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dfgsdgsdgsd](https://discourse.crowdsec.net/u/dfgsdgsdgsd)\
**Post date:** [November 6, 2024, 6:55pm UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/1 "2024-11-06T18:55:58Z")

</div>

Hi,

is it possible to secure a docker instance of Nginx Proxy Manager with Crowdsec (native insalled on this Ubunut 24.0.4 VPS Server)?

Im using this image for the NPM: jc21/nginx-proxy-manager:latest

I learned that crowdsec will not work with this jc21 image and you need to change the image to this one:  
lepresidente/nginx-proxy-manager:latest

Doing this, I can not login into my NPM instance anymore and when switching back to the jc21 image, the whole setup is not working anymore.

Is there a working way to get Crowdsec working with the Nginx proxy manager?

Thanks

---

<div class="post-metadata">

**Author:** ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)\
**Post date:** [November 7, 2024, 8:20am UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/2 "2024-11-07T08:20:11Z")

</div>

> [@dfgsdgsdgsd](#):
>
> I learned that crowdsec will not work with this jc21 image and you need to change the image to this one:

this is incorrect, it does work with the `jc21` image, however, since `jc21` image does not ship with a [remediation component](https://docs.crowdsec.net/u/bouncers/intro) installed there is no way within that image to enforce decisions that crowdsec makes (we can still parse the logs and make decisions just no enforcement on that side hence the paragraph below). Hence `lepresidente` has a fork of the image to do this, I see alot of people are also turning to [NPMPlus](https://github.com/ZoeyVid/NPMplus) maintained by another user.

Now you can use the [linux firewall remediation](https://docs.crowdsec.net/u/bouncers/firewall) to enforce decisions but this _only_ works if you do not use an upstream proxy like cloudflare as when proxy is enabled at layer 3/4 all the firewall can see is the cloudflare ip address not the proxied IP that is at layer 7.

---

<div class="post-metadata">

**Author:** ![dfgsdgsdgsd](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dfgsdgsdgsd](https://discourse.crowdsec.net/u/dfgsdgsdgsd)\
**Post date:** [November 7, 2024, 9:29pm UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/3 "2024-11-07T21:29:29Z")

</div>

Sorry, I don’t understand your answer. What is possible whit the JC21 which is not possible or possible with the one of lepresidente? What are the advantages of lepresidente?  
As mentioned I already use CrowdSec with the Firewall Bouncer for the SSH service. No cloud flare involved.

---

<div class="post-metadata">

**Author:** ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)\
**Post date:** [November 8, 2024, 9:07am UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/4 "2024-11-08T09:07:14Z")

</div>

> [@dfgsdgsdgsd](#):
>
> . What is possible whit the JC21 which is not possible or possible with the one of lepresidente?

You can block request on the within Nginx itself rather than relying on the firewall this is _only_ useful if you want to use captcha remediation.

If you already use the firewall bouncer then you can enable the `DOCKER_USER` chain within the configuration file, then this will start blocking request that are proxied by docker, as docker uses NAT to expose services you must enable this chain.

---

<div class="post-metadata">

**Author:** ![dfgsdgsdgsd](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dfgsdgsdgsd](https://discourse.crowdsec.net/u/dfgsdgsdgsd)\
**Post date:** [November 8, 2024, 10:22pm UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/5 "2024-11-08T22:22:16Z")

</div>

Sorry, still do not get what should be the difference betweenn the JC21 and the Lepresidente Image.  
Aas mentioned I use the JC21 image, crowdsec already installed on the machine, securing e.g. the SSH service.  
Firewall bouncer enabled. UFW+ufw docker enabled on the host

---

<div class="post-metadata">

**Author:** ![dfgsdgsdgsd](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dfgsdgsdgsd](https://discourse.crowdsec.net/u/dfgsdgsdgsd)\
**Post date:** [November 9, 2024, 5:29pm UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/6 "2024-11-09T17:29:49Z")

</div>

Would be great if anyone can explain more

---

<div class="post-metadata">

**Author:** ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)\
**Post date:** [November 11, 2024, 3:12pm UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/7 "2024-11-11T15:12:38Z")

</div>

> [@dfgsdgsdgsd](#):
>
> still do not get what should be the difference betweenn the JC21 and the Lepresidente Image.

The difference is the jc21 image does not have [this remediation component](https://docs.crowdsec.net/u/bouncers/openresty) installed within it as Lepresidente fork does.

If you dont use an upstream proxy like cloudflare then you can just use jc21 image, point crowdsec towards the logs, enable `DOCKER_USER` chain within the `firewall bouncer` configuration and thats it.

You dont _have to_ to use Lepresidente fork, its just there as an option if you _do_ use an upstream proxy like cloudflare.

---

<div class="post-metadata">

**Author:** ![dfgsdgsdgsd](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dfgsdgsdgsd](https://discourse.crowdsec.net/u/dfgsdgsdgsd)\
**Post date:** [November 13, 2024, 6:00pm UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/8 "2024-11-13T18:00:41Z")

</div>

Ok, got that JC21 images works.

But still missing, what the advantage of this remediation component, besides supporting cloudflare.

---

<div class="post-metadata">

**Author:** ![codewithcj](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@codewithcj](https://discourse.crowdsec.net/u/codewithcj)\
**Post date:** [January 4, 2025, 1:26am UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/9 "2025-01-04T01:26:01Z")

</div>

> [@iiAmLoz](#):
>
> You dont _have to_ to use Lepresidente fork, its just there as an option if you _do_ use an upstream proxy like cloudflare.

I am using Cloudflare Tunnel. I have below questions.

- Lepresidente fork seems to be last updated several months ago. When will this be updated again?
- Is Captch is the only option it provides?
- I am using Vaultwarden and I am afraid it may not support captcha based revalidation? Also, I want to stay with original jc21 image as I will get updates immediately. In that case, will crowdsec be useful? I tried to ban a IP, but still I am able to connect to my vaultwardern. Is this due to clouflare? Any workaround or suggestion?

---

<div class="post-metadata">

**Author:** ![iiAmLoz](https://dub1.discourse-cdn.com/flex013/user_avatar/discourse.crowdsec.net/iiamloz/32/386_2.png) [@iiAmLoz](https://discourse.crowdsec.net/u/iiAmLoz)\
**Post date:** [January 6, 2025, 8:35am UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/10 "2025-01-06T08:35:50Z")

</div>

> [@codewithcj](#):
>
> Lepresidente fork seems to be last updated several months ago. When will this be updated again?

Dont know we are not `LePresidente`, best to open an issue on the github fork

> Is Captcha is the only option it provides?

No it provides ban and captcha

> I am using Vaultwarden and I am afraid it may not support captcha based revalidation? Also, I want to stay with original jc21 image as I will get updates immediately. In that case, will crowdsec be useful? I tried to ban a IP, but still I am able to connect to my vaultwardern. Is this due to clouflare? Any workaround or suggestion?

Well the issue here is you cannot just use the firewall remediation as when using cloudflare with proxy enabled, the firewall can only see cloudflare ip address connecting at layer 3/4. Only other suggestion is either use a cloudflare remediation but that comes with various limits if you are on the free plan OR use another fork which is updated regularly like [NPMPlus by ZoeyVid](https://github.com/ZoeyVid/NPMplus),

---

<div class="post-metadata">

**Author:** ![codewithcj](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@codewithcj](https://discourse.crowdsec.net/u/codewithcj)\
**Post date:** [January 6, 2025, 8:57pm UTC](https://discourse.crowdsec.net/t/secure-nginx-proxy-manager-docker-instance-with-crowdsec/2125/11 "2025-01-06T20:57:17Z")

</div>

> [@iiAmLoz](#):
>
> cloudflare remediation but that comes with various limits

I am having free plan and it started throwing limit notification every day. Is there a way to run custom command for firewall bouncer whenever it deduct bad IPs?  
I configured fail2ban to block an IP via its Cloudflare functionality. But I am afraid it uses very basic method (log parsing using regex to find bad IPs). Instead of I can combine it with firewall bouncer offered by crowdsec, then i won’t run into limit issue as Fail2ban uses some API to directly ban bad IPs that tries to connect my server instead of trying to add entire community list.
