Yes, it is possible to integrate ModSecurity with HAProxy, but it requires using ModSecurity as a standalone service with HAProxy’s Stream Processing Offload Engine (SPOE) and a Stream Processing Offload Agent (SPOA), such as jcmoraisjr/modsecurity-spoa. This approach offloads ModSecurity’s processing to a dedicated agent, allowing HAProxy to filter HTTP traffic through ModSecurity rules without embedding ModSecurity directly into HAProxy. Below, I’ll outline the steps to achieve this integration, focusing on a typical setup using a Linux distribution like CentOS or Ubuntu, and address the feasibility based on your context.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| If your redis initial replication fails with error like | |
| "5101:M 20 Feb 18:14:29.130 # Client id=4500196 addr=71.459.815.760:43872 fd=533 name= age=127 idle=127 flags=S db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=13997 oll=1227 omem=192281275 events=rw cmd=psync scheduled to be closed ASAP for overcoming of output buffer limits. | |
| this means that slave buffer is not enough and you should increase it (at master!) with command like | |
| redis-cli config set client-output-buffer-limit "slave 836870912 836870912 0" | |
| more info: https://redis.io/topics/clients |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| All actions are performed in Terminal.app. | |
| 1. Install Homebrew http://brew.sh/ | |
| 2. Install Jack (route audio tool) http://jackaudio.org/. Current stable version from official website doesn't work with | |
| MacOS Sierra (I use 10.12.3) so you need to download beta version from there https://yadi.sk/d/JwT10b7v3Dm5yy. | |
| After installing reboot your computer. | |
| 3. Install Darkice (audio streamer) via brew. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Make sure you have these installed | |
| yum install -y make gcc perl pcre-devel zlib-devel | |
| # Download/Extract source | |
| wget -O /tmp/haproxy.tgz http://www.haproxy.org/download/1.7/src/haproxy-1.7.2.tar.gz | |
| tar -zxvf /tmp/haproxy.tgz -C /tmp | |
| cd /tmp/haproxy-* | |
| # Compile HAProxy | |
| # https://github.com/haproxy/haproxy/blob/master/README | |
| make \ | |
| TARGET=linux2628 USE_LINUX_TPROXY=1 USE_ZLIB=1 USE_REGPARM=1 USE_PCRE=1 USE_PCRE_JIT=1 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vrrp_script chk_redis_master { | |
| script "redis-cli info replication | grep -q 'role:master'" | |
| interval 2 | |
| weight 2 | |
| rise 2 | |
| fall 2 | |
| } | |
| vrrp_instance redis_vip { | |
| interface eth0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var traverse = function(o, fn) { | |
| for (var i in o) { | |
| fn.apply(this,[i,o[i]]); | |
| if (o[i] !== null && typeof(o[i])=="object") { | |
| traverse(o[i], fn); | |
| } | |
| } | |
| } | |
| // usage |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This script will boot app.js with the number of workers | |
| // specified in WORKER_COUNT. | |
| // | |
| // The master will respond to SIGHUP, which will trigger | |
| // restarting all the workers and reloading the app. | |
| var cluster = require('cluster'); | |
| var workerCount = process.env.WORKER_COUNT || 2; | |
| // Defines what each worker needs to run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // To disable socket.io, disable the sockets hook (you'll have to disable the pubsub hook as well) | |
| // This is a replacement for the default app.js file: | |
| require('sails').lift({ | |
| hooks: { | |
| sockets: false, | |
| pubsub: false | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
| class MY_Session extends CI_Session{ | |
| private $sess_use_redis = TRUE; | |
| private $redis = ''; | |
| public function __construct($params = array()) { | |
| //parent::__construct(); | |
| $this->CI =& get_instance(); |
NewerOlder