Best Bouncer Configuration for AppSec on a LAMP Server

Hello, I have a question. I currently have several LAMP web servers, notably with Apache2 + PHP. Right now, I’d like to set up AppSec, but first I want to install the appropriate bouncers. I see that there is a bouncer for PHP and another for Apache. What would you recommend? Should I install both, or just one of them? Which one would work best with AppSec? Thank you in advance.
34 Replies
CrowdSec
CrowdSecβ€’5mo ago
Important Information
Thank you for getting in touch with your support request. To expedite a swift resolution, could you kindly provide the following information? Rest assured, we will respond promptly, and we greatly appreciate your patience. While you wait, please check the links below to see if this issue has been previously addressed. If you have managed to resolve it, please use run the command /resolve or press the green resolve button below.
Log Files
If you possess any log files that you believe could be beneficial, please include them at this time. By default, CrowdSec logs to /var/log/, where you will discover a corresponding log file for each component.
Guide Followed (CrowdSec Official)
If you have diligently followed one of our guides and hit a roadblock, please share the guide with us. This will help us assess if any adjustments are necessary to assist you further.
Screenshots
Please forward any screenshots depicting errors you encounter. Your visuals will provide us with a clear view of the issues you are facing.
© Created By WhyAydan for CrowdSec ❀️
blotus
blotusβ€’5mo ago
Hello, You will only need one of them. The PHP bouncer does support appsec, and the apache bouncer does not.
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
Great, thanks a lot! I just tried to set this up, but I couldn’t find any specific documentation. I mixed several docs to manage to implement the PHP bouncer + appsec + captcha. However, I’ve reached a point where I defined the captcha for certain scenarios, but when I trigger it, nothing happens. Do you have any idea why?
No description
No description
No description
blotus
blotusβ€’5mo ago
is the index page generated by PHP code ? The PHP bouncer will only work if the content of the page was generated by PHP
blotus
blotusβ€’5mo ago
and if you add a "normal" decision, do you get a 403 ? What does cscli bouncers list show ?
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
When I remove the captcha decision, I get banned. But when I put the captcha decision back, I still don’t see any captcha.
No description
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
I don't know why I'm not getting a 403, only 200 responses.
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
Hmmmm nevermind, actually it happens after a certain amount of time, it doesn’t block me instantly
No description
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
So for now, there's only a captcha issue on my machine.
blotus
blotusβ€’5mo ago
I don't know how often the bouncer will refresh, but most bouncers update their cache every 10 seconds it depends on the cron you setup the docs has an exemple for every 15 minutes but with a cron, you won't be able to go under a minute
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
i have :
*/10 * * * * /usr/bin/php /var/www/crowdsec-standalone-bouncer/scripts/refresh-cache.php
0 0 * * * /usr/bin/php /var/www/crowdsec-standalone-bouncer/scripts/prune-cache.php
0 0 * * * /usr/bin/php /var/www/crowdsec-standalone-bouncer/scripts/push-usage-metrics.php
*/10 * * * * /usr/bin/php /var/www/crowdsec-standalone-bouncer/scripts/refresh-cache.php
0 0 * * * /usr/bin/php /var/www/crowdsec-standalone-bouncer/scripts/prune-cache.php
0 0 * * * /usr/bin/php /var/www/crowdsec-standalone-bouncer/scripts/push-usage-metrics.php
blotus
blotusβ€’5mo ago
if you want instant update, you will need to use live mode which will make a query to LAPI for each request processed by your app (with some cache on top of that)
blotus
blotusβ€’5mo ago
set stream_mode to false in the bouncer config to enable live mode (it's the default, I don't know if you changed it or not) and for the captcha issue: - can you check the actual content of the response ? I don't know which HTTP the bouncer uses to send the captcha page - Set debug_mode to truein the config, it should log more informations about what is happening
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
No, I haven’t changed the stream_mode. However, when I modify the settings.php, do I need to restart Apache2 and CrowdSec?
blotus
blotusβ€’5mo ago
only apache
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
That's why I removed the firewall bouncer, I only have the PHP bouncer to test, so there's no risk of conflict between two bouncers.
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
I just tested it on a standard configuration, and even there the captcha doesn't appear. Aside from the standard installation, is there anything else that needs to be installed?
No description
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
time="2025-07-25T10:49:38+02:00" level=debug msg="dbg(result=true): Alert.Remediation == true && Alert.GetScope() == \"Ip\"" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [true] " name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== true] true == true -> [true]" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [&&] AND -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== \"Ip\"] \"Ip\" == \"Ip\" -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg="dbg(result=true): Alert.Remediation == true && Alert.GetScope() == \"Ip\"" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [true] " name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== true] true == true -> [true]" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [&&] AND -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== \"Ip\"] \"Ip\" == \"Ip\" -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg="dbg(result=true): Alert.Remediation == true && Alert.GetScope() == \"Ip\"" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [true] " name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== true] true == true -> [true]" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [&&] AND -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== \"Ip\"] \"Ip\" == \"Ip\" -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg="dbg(result=true): Alert.Remediation == true && Alert.GetScope() == \"Ip\"" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [true] " name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== true] true == true -> [true]" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [&&] AND -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== \"Ip\"] \"Ip\" == \"Ip\" -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=info msg="(1b41d35b393a436081366746838d1b760yB17KXpe1D09xqG/crowdsec) crowdsecurity/http-backdoors-attempts by ip 192.168.122.1 : 4h captcha on Ip 192.168.122.1"
time="2025-07-25T10:49:38+02:00" level=info msg="(1b41d35b393a436081366746838d1b760yB17KXpe1D09xqG/crowdsec) crowdsecurity/fortinet-cve-2018-13379 by ip 192.168.122.1 : 4h captcha on Ip 192.168.122.1"
time="2025-07-25T10:49:38+02:00" level=info msg="(1b41d35b393a436081366746838d1b760yB17KXpe1D09xqG/crowdsec) crowdsecurity/f5-big-ip-cve-2020-5902 by ip 192.168.122.1 : 4h captcha on Ip 192.168.122.1"
time="2025-07-25T10:49:38+02:00" level=info msg="(1b41d35b393a436081366746838d1b760yB17KXpe1D09xqG/crowdsec) crowdsecurity/http-open-proxy by ip 192.168.122.1 : 4h captcha on Ip 192.168.122.1"
time="2025-07-25T10:49:42+02:00" level=info msg="Signal push: 9 signals to push"
time="2025-07-25T10:49:38+02:00" level=debug msg="dbg(result=true): Alert.Remediation == true && Alert.GetScope() == \"Ip\"" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [true] " name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== true] true == true -> [true]" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [&&] AND -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== \"Ip\"] \"Ip\" == \"Ip\" -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg="dbg(result=true): Alert.Remediation == true && Alert.GetScope() == \"Ip\"" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [true] " name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== true] true == true -> [true]" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [&&] AND -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== \"Ip\"] \"Ip\" == \"Ip\" -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg="dbg(result=true): Alert.Remediation == true && Alert.GetScope() == \"Ip\"" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [true] " name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== true] true == true -> [true]" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [&&] AND -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== \"Ip\"] \"Ip\" == \"Ip\" -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg="dbg(result=true): Alert.Remediation == true && Alert.GetScope() == \"Ip\"" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [true] " name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== true] true == true -> [true]" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [&&] AND -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=debug msg=" [== \"Ip\"] \"Ip\" == \"Ip\" -> true" name=default_ip_remediation type=profile
time="2025-07-25T10:49:38+02:00" level=info msg="(1b41d35b393a436081366746838d1b760yB17KXpe1D09xqG/crowdsec) crowdsecurity/http-backdoors-attempts by ip 192.168.122.1 : 4h captcha on Ip 192.168.122.1"
time="2025-07-25T10:49:38+02:00" level=info msg="(1b41d35b393a436081366746838d1b760yB17KXpe1D09xqG/crowdsec) crowdsecurity/fortinet-cve-2018-13379 by ip 192.168.122.1 : 4h captcha on Ip 192.168.122.1"
time="2025-07-25T10:49:38+02:00" level=info msg="(1b41d35b393a436081366746838d1b760yB17KXpe1D09xqG/crowdsec) crowdsecurity/f5-big-ip-cve-2020-5902 by ip 192.168.122.1 : 4h captcha on Ip 192.168.122.1"
time="2025-07-25T10:49:38+02:00" level=info msg="(1b41d35b393a436081366746838d1b760yB17KXpe1D09xqG/crowdsec) crowdsecurity/http-open-proxy by ip 192.168.122.1 : 4h captcha on Ip 192.168.122.1"
time="2025-07-25T10:49:42+02:00" level=info msg="Signal push: 9 signals to push"
blotus
blotusβ€’5mo ago
no it should work out of the box with the PHP bouncer Can you set debug_mode to true in the bouncer configuration, make a request (from an IP that has a captcha decision) and paste the logs ?
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
Are the logs actually in crowdsec.log (php bouncer) ? Because it doesn't seem like enabling debug mode changes anything.
blotus
blotusβ€’5mo ago
no they are emitted by PHP so they should be where your PHP logs
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
Sorry, I hadn’t noticed that the logs were in $dir/.logs. So, here are the logs in debug mode.
blotus
blotusβ€’5mo ago
so the bouncer think the captcha has been already solved, and does not show it again (this is by design, in order to avoid showing the captcha to the user for each request) Have you solved the captcha once ? The default cache duration for the captcha is 24h
blotus
blotusβ€’5mo ago
yes you can change it to a lower value by setting captcha_cache_duration in the config to a value in seconds
blotus
blotusβ€’5mo ago
Sorry, I should have thought about this earlier, but I've never actually used this bouncer (the further away I am from PHP, the better :D)
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
It's my fault, I should have read more carefully. However, I modified the value, but it still considers it as "solved". I think it has the last value cached β€” how can I clear the cache?
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
And just to be sure, I only need to specify it like this, right?
No description
blotus
blotusβ€’5mo ago
yes that should work To clear the cache, you can run the prune-cache.php script
πŸ…±πŸ…±πŸ†„πŸ…³πŸ…³πŸ…·πŸ…°
Okay, I just ran some tests. I'm not sure why, but when I run php prune-cache.php, it doesn't work, whereas php clear-prune.php does. Note that there's nothing in the logs when I run prune-cache.php. But it's fine, it's working now. I also noticed that when I get banned, I see the "Oh" page. However, when I unban myself, it takes between 1 and 2 minutes before I can access the page again. Do you know why that might be? Because I do have stream_mode set to false.

Did you find this page helpful?