My website is down when BitNinja is running (Error 502 /504)

You are here:
Estimated reading time: 1 min
If you see an error on your screen with a 5xx error the issue might be solved differently based on your configuration or set up.

First, we need to check what kind of error code do you see.

Error 502

If you see this screen when you try to access a domain that is behind CloudFlare while BitNinja is running with the WAF module enabled and the Trusted proxy module enabled.

  1. Issue bitninjacli --module=SslTerminating --regenerate
  2. Wait for a minute to make sure the command went trough
  3. Run bitninjacli --module=SslTerminating --reload

Then all domains that are behind Cloudflare should be reachable from now.

504 Gateway Time-out

If you see a time-out error 504 from Nginx like on this screenshot we need to increase the timeout threshold in the Nginx config of the WAF 2.0 module.

  1. Make this directory mkdir /opt/bitninja-waf/etc/local_configs
  2. Create a global_proxy.conf file and write the time period required after the proxy_read_timeout variable in seconds.
    e.g.: echo "proxy_read_timeout 180s;" > /opt/bitninja-waf/etc/local_configs/global_proxy.conf
  3. Reload the WAF 2.0 modules configuration with bitninjacli --module=WAFManager --reload command
  4. Open the /etc/bitninja/SslTerminating/config.ini file with your preferred text editor. e.g.: nano /etc/bitninja/SslTerminating/config.ini
  5. Remove the semicolon from the lines below the [haproxyDefaultSettings] section. The values in the file are increased compared to the default actual values.
    ;timeout[] = 'connect 5000'
    ;timeout[] = 'client 50000'
    ;timeout[] = 'server 50000'
  6. Change the values according to your needs. The variables are in milliseconds. (50000ms = 50s)
  7. Regenerate and reload the SSL terminating module with these two commands:
    bitninjacli --module=SSLTerminating --regenerate
    bitninjacli --module=SSLTerminating --reload
If You experience any other errors please don’t hesitate to contact us via Chat from the Dashboard or by sending an email to
You can also send us a ticket here.

Views: 1123