13 ноября 2019 г.

AWS SDK cURL error 28 Connection timed out

If when using Amazon / AWS PHP SDK (for e.g. AWS SES) you're getting this error
cURL error 28: Connection timed out after 1001 milliseconds
make sure you got the credentials right; pay attention to the key nesting (i.e. key and secret go under credentials)
$client = SesClient::factory(array(
  'version'   => 'latest',
  'region'    => 'eu-north-1',
  'credentials' => array(
    'key'       => AWS_KEY,
    'secret'    => AWS_SECRET,
This may not be a network connection problem after all. more info

14 октября 2019 г.

fail2ban bans wrong port with iptables

If you created a custom non-SSH action for fail2ban, and while it does get triggered, the offender can still get through, make sure you've used the right iptables ban action. iptables-multiport will work with the ports you specify next to it in your config; if you don't specify any, it reverts to 22 (default SSH). My custom action.d was for Nginx (ports 80 and 443), and the ban essentially didn't work. The key is to use iptables-allports - it will ban the offender completely, regardless of ports, and using it seems to make the most sense anyway. You can check which port was banned by running iptables -L and looking for the chain name matching your jail name. Source: https://serverfault.com/a/382891

24 сентября 2019 г.

ip address abuse contact whois api

https://stackoverflow.com/questions/48842347/whois-command-and-whois-rest-api-giving-different-results-for-ip-address RIPE: - https://github.com/RIPE-NCC/whois/wiki/WHOIS-REST-API - https://github.com/RIPE-NCC/whois/wiki/WHOIS-REST-API-abuse-contact https://rest.db.ripe.net/search.json?query-string= https://rest.db.ripe.net/abuse-contact/ ARIN: http://whois.arin.net/rest/ip/

31 мая 2019 г.

mysql rsnapshot backup separate database table files

Backing up MySQL databases and tables as separate files with rsnapshot. Simply copying /var/lib/mysql won't always work, so the databases need to be exported.

First, create a separate MySQL user backup with these limited to read-only permissions: LOCK TABLES, SELECT, SHOW VIEW.

Install rsync - otherwise you'd get bash: rsync: command not found; rsync: connection unexpectedly closed.

Then set up this script:

#! /bin/bash

MYSQL=$(which mysql)
MYSQLDUMP=$(which mysqldump)

databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`

for db in $databases; do
  for tbl in `$MYSQL -u $MYSQL_USER -p$MYSQL_PASSWORD -N -B -e "SHOW TABLES FROM $db"`; do
    mkdir -p "$(dirname ${VAR_LOCATION})"
    $MYSQLDUMP --skip-comments --compact -u $MYSQL_USER -p$MYSQL_PASSWORD $db $tbl > "${VAR_LOCATION}"

The above is a combination of these scripts from mensfeld.pl and jamescoyle.net.

I previously tried using the following line from this answer:

mysqldump --user=dbuser --password --tab=~/output/dir dbname
But that doesn't work, really: it throws Access denied (using password: YES) when executing 'SELECT INTO OUTFILE' because it requires a special kind of GRANT you can't easily set via the MySQL Workbench UI. After all, you end up with a CSV backup which you have to treat differently.

16 апреля 2019 г.

4 апреля 2019 г.

cakephp 3 multiple levels deep prefix

Router::prefix('api', function ($routes) {
    $routes->prefix('users', function ($routes) {

namespace App\Controller\Api\Users;

use App\Controller\AppController;
use Cake\Event\Event;
use Cake\ORM\TableRegistry;

class UsersController extends AppController

    public function index()
        // ...


1 февраля 2019 г.

dompdf setPaper size orientation not working

According to the Usage page, in order to set the paper size and orientation you need to call setPaper(). However, this won't work if in your actual HTML you're rendering you have page size definition such as this:
    @page {
        margin: 0;
        padding: 0;
        size: 210mm 297mm;
    html {
        margin: 0;
        padding: 0;
    body {
        margin: 0;
        padding: 0;
This will override whatever you set with setPaper(). Either remove it, or edit it.