среда, 9 октября 2019 г.

Wildcard certificate from Let's Encrypt

If you need wildcard certificate from Let's Encrypt for your domain, you can use certbot to do it.

First of all, you should have access to your dns to create TXT records like this

_acme-challenge.domain.com IN TXT   "some_value"

Second - install certbot

yum install -y certbot


then make a request like this:

certbot certonly --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory --manual-public-ip-logging-ok -d '*.domain.com' -d domain.com


During a dialog, you will receive wich TXT record you should put in your DNS




понедельник, 23 сентября 2019 г.

MariaDB create master slave replication

First of all, you should check mariadb server config file(usually it /etc/my.cnf.d/server.cnf) on master and slave server. There are must present on the master:
[mariadb]
binlog_format=MIXED
log-bin
server_id=1
and on the slave:
[mariadb]
binlog_format=MIXED
log-bin
server_id=2
Also, you should create user for replication and grant privileges to him:
create user 'replication_user'@'$SLAVE_IP' identified by '$PASSWORD';
grant replication slave on *.* to 'replication_user'@'$SLAVE_IP';
flush privileges;

Then you should login to the master database and lock tables to read status, get master log file and position and create databases dump:
FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.08 sec)
SHOW MASTER STATUS;
+-------------------+-----------+--------------+------------------+
| File              | Position  | Binlog_Do_DB | Binlog_Ignore_DB |
+-------------------+-----------+--------------+------------------+
| master-bin.003437 | 852552729 |              |                  |
+-------------------+-----------+--------------+------------------+
in another screen create database dump:
mysqldump -u root -p -A | gzip > all_db_dump.sql.gz 

or you can use without lock tables:
mysqldump -u root -p -v --insert-ignore --skip-lock-tables --single-transaction=TRUE -A | gzip >  all_db_dump,sql.gz

after dump created, unlock tables:
UNLOCK TABLES;
Query OK, 0 rows affected (0.00 sec)

On the slave server drop and create empty users' databases and import data :
gunzip < all_db_dump.sql.gz | mysql -u root -p 
Then stop slave:
STOP SLAVE;
and create replication on the slave server :
CHANGE MASTER TO 
MASTER_HOST='$MASTER_IP', 
MASTER_USER='replication_user', 
MASTER_PASSWORD='$PASSWORD', 
MASTER_PORT=3306, 
MASTER_LOG_FILE='master-bin.003437', 
MASTER_LOG_POS=852552729, 
MASTER_CONNECT_RETRY=10;

and start slave:
START SLAVE;

After that you can check slave status:
SHOW SLAVE STATUS\G

четверг, 10 января 2019 г.

Moving /var/lib/docker to another drive

For example : we have a VM with docker , but we need to move directory /var/lib/docker to separate partition or HDD:
 lvs
  LV            VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home          centos -wi-ao---- 20.00g                                                    
  root          centos -wi-ao---- 25.80g                                                    
  swap          centos -wi-ao----  2.00g                                                    
  tmp           centos -wi-ao----  2.00g                                                    
  var           centos -wi-ao---- 25.00g                                                    
  var_log       centos -wi-ao---- 20.00g                                                    
  var_log_audit centos -wi-ao----  2.00g                                                    
  var_tmp       centos -wi-ao----  2.00g  

df -h
File system                 Size Used Available Used%  Mounted
/dev/mapper/centos-root             26G         5.7G   19G           24% /
devtmpfs                           858M            0  858M            0% /dev
tmpfs                              870M            0  870M            0% /dev/shm
tmpfs                              870M         9.4M  860M            2% /run
tmpfs                              870M            0  870M            0% /sys/fs/cgroup
/dev/sda2                          976M         407M  503M           45% /boot
/dev/sda1                          200M          19M  182M           10% /boot/efi
/dev/mapper/centos-var              25G         3.2G   21G           14% /var
/dev/mapper/centos-tmp             2.0G          33M  1.8G            2% /tmp
/dev/mapper/centos-var_log          20G         397M   19G            3% /var/log
/dev/mapper/centos-home             20G         115M   19G            1% /home
/dev/mapper/centos-var_log_audit   2.0G          35M  1.8G            2% /var/log/audit
/dev/mapper/centos-var_tmp         2.0G         160M  1.7G            9% /var/tmp
tmpfs                              174M            0  174M            0% /run/user/1000


So add new HDD and check in OS:
lsblk 
NAME                     MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                        8:0    0  100G  0 disk 
├─sda1                     8:1    0  200M  0 part /boot/efi
├─sda2                     8:2    0    1G  0 part /boot
└─sda3                     8:3    0 98.8G  0 part 
  ├─centos-root          253:0    0 25.8G  0 lvm  /
  ├─centos-swap          253:1    0    2G  0 lvm  [SWAP]
  ├─centos-tmp           253:2    0    2G  0 lvm  /tmp
  ├─centos-var           253:3    0   25G  0 lvm  /var
  ├─centos-var_tmp       253:4    0    2G  0 lvm  /var/tmp
  ├─centos-var_log       253:5    0   20G  0 lvm  /var/log
  ├─centos-var_log_audit 253:6    0    2G  0 lvm  /var/log/audit
  └─centos-home          253:7    0   20G  0 lvm  /home
sdb                        8:16   0   40G  0 disk 
sr0                       11:0    1 1024M  0 rom  

fdisk -l /dev/sdb

Disk /dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Create new LVM partition on new HDD:

parted -s /dev/sdb mklabel gpt; parted -s /dev/sdb unit mib mkpart primary 1 100% set 1 lvm on

fdisk -l /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdb: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: gpt
Disk identifier: 47E3AF39-FFC1-470E-A40A-334150007411


#         Start          End    Size  Type            Name
 1         2048     83884031     40G  Linux LVM       primary


pvs
  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda3  centos lvm2 a--  98.80g    0 

Create new physical group:
pvcreate /dev/sdb1 
  Physical volume "/dev/sdb1" successfully created.

pvs
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/sda3  centos lvm2 a--   98.80g      0 
  /dev/sdb1         lvm2 ---  <40.00g <40.00g

New volume group:
vgcreate docker /dev/sdb1
  Volume group "docker" successfully created

pvs
  PV         VG     Fmt  Attr PSize   PFree  
  /dev/sda3  centos lvm2 a--   98.80g      0 
  /dev/sdb1  docker lvm2 a--  <40.00g <40.00g

New logical volume:
lvcreate -l100%FREE docker -n var_lib_docker
  Logical volume "var_lib_docker" created.

lvs
  LV             VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home           centos -wi-ao----  20.00g                                                    
  root           centos -wi-ao----  25.80g                                                    
  swap           centos -wi-ao----   2.00g                                                    
  tmp            centos -wi-ao----   2.00g                                                    
  var            centos -wi-ao----  25.00g                                                    
  var_log        centos -wi-ao----  20.00g                                                    
  var_log_audit  centos -wi-ao----   2.00g                                                    
  var_tmp        centos -wi-ao----   2.00g                                                    
  var_lib_docker docker -wi-a----- <40.00g                             

And make ext4 file system on the new volume:

mkfs.ext4 /dev/mapper/docker-var_lib_docker 
mke2fs 1.42.9 (28-Dec-2013)
Discarding device blocks: done                            
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
2621440 inodes, 10484736 blocks
524236 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2157969408
320 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
4096000, 7962624

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   


Mount new volume to empty directory:

mount /dev/mapper/docker-var_lib_docker /mnt/

Check it:

mount | column -t | grep mnt
/dev/mapper/docker-var_lib_docker  on  /mnt                             type  ext4        (rw,relatime,data=ordered)

Stop docker service:

systemctl stop docker

and check open files in /var/lib/docker:

lsof /var/lib/docker

Now rsync data from /var/lib/docker  to /mnt and remove files and dirs on source:

rsync -avr --remove-source-files --prune-empty-dirs   /var/lib/docker/* /mnt/ && find /var/lib/docker -depth=1  -type d -empty -exec rmdir "{}" \; && mkdir /var/lib/docker

Then umount /mnt :

umount /mnt

Add new mount point to /etc/fstab:

echo  "/dev/mapper/docker-var_lib_docker  /var/lib/docker      ext4    defaults        1 2" >> /etc/fstab

and mount new logical volume :

mount -a

check block devices and mounts:

 lsblk 
NAME                      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                         8:0    0  100G  0 disk 
├─sda1                      8:1    0  200M  0 part /boot/efi
├─sda2                      8:2    0    1G  0 part /boot
└─sda3                      8:3    0 98.8G  0 part 
  ├─centos-root           253:0    0 25.8G  0 lvm  /
  ├─centos-swap           253:1    0    2G  0 lvm  [SWAP]
  ├─centos-tmp            253:3    0    2G  0 lvm  /tmp
  ├─centos-var            253:4    0   25G  0 lvm  /var
  ├─centos-var_tmp        253:5    0    2G  0 lvm  /var/tmp
  ├─centos-var_log        253:6    0   20G  0 lvm  /var/log
  ├─centos-var_log_audit  253:7    0    2G  0 lvm  /var/log/audit
  └─centos-home           253:8    0   20G  0 lvm  /home
sdb                         8:16   0   40G  0 disk 
└─sdb1                      8:17   0   40G  0 part 
  └─docker-var_lib_docker 253:2    0   40G  0 lvm  /var/lib/docker

and start docker service;

systemctl start docker





четверг, 15 ноября 2018 г.

Change Python from 2.7 to 3.4 ver in Centos7

Sometime you would be swith from default python version (2.7) on Centos 7 to more new for expample 3.4.
In such case you can use next:

Check Python version:

python -V
Python 2.7.5

install more new:

yum install -y python34 

and check python version registered via alternatives :

alternatives --list | grep -i python

If it output empty , you can set new alternatives:

alternatives --install /usr/bin/python python /usr/bin/python3.4 2
alternatives --install /usr/bin/python python /usr/bin/python2.7 1

and check Python version :
python -V
Python 3.4.9

Now you have to set exactly version in files /bin/yum and /usr/libexec/urlgrabber-ext-down: 
replace /usr/bin/python to /usr/bin/python2.7 in the first rows.

That's all. 

среда, 13 декабря 2017 г.

How to move virtuozzo 7 on packet.net to software raid1

After installation Type 1 node on packet.net we have same scheme block device:
lsblk 
NAME              MAJ:MIN    RM   SIZE RO TYPE  MOUNTPOINT
sda                 8:0       0 223.6G  0 disk  
├─sda1              8:1       0     2M  0 part  
├─sda2              8:2       0   256M  0 part  /boot
├─sda3              8:3       0     8G  0 part  [SWAP]
└─sda4              8:4       0 215.3G  0 part  /
sdb                 8:16      0 223.6G  0 disk  
└─mpathb          253:0       0 223.6G  0 mpath 
ploop17991        182:287856  0    10G  0 disk  
└─ploop17991p1    182:287857  0    10G  0 part  /vz/pfcache

Check disk labels:

fdisk -l /dev/sda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: C63AA19D-6E91-4A1E-976D-899D800EC489


#         Start          End    Size  Type            Name
 1         2048         6143      2M  BIOS boot parti BIOS
 2         6144       530431    256M  Linux filesyste BOOT
 3       530432     17307647      8G  Linux filesyste SWAP
 4     17307648    468862094  215.3G  Linux filesyste ROOT
fdisk -l /dev/sdb

Disk /dev/sdb: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

and create gpt label on /dev/sdb:

parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt                                                      
(parted) q                                                                
Information: You may need to update /etc/fstab.

fdisk -l /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdb: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: 2F21C828-C60E-4DBD-AC6B-DDA2B119B92D
#         Start          End    Size  Type            Name


Now create partitions on /dev/sdb like /dev/sda but need set Type RAID for all partitions except BIOS boot  partiotions:

fdisk -l /dev/sda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sda: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: C63AA19D-6E91-4A1E-976D-899D800EC489


#         Start          End    Size  Type            Name
 1         2048         6143      2M  BIOS boot parti BIOS
 2         6144       530431    256M  Linux filesyste BOOT
 3       530432     17307647      8G  Linux filesyste SWAP
 4     17307648    468862094  215.3G  Linux filesyste ROOT
fdisk /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sdb: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: 2F21C828-C60E-4DBD-AC6B-DDA2B119B92D


#         Start          End    Size  Type            Name

Command (m for help): n
Partition number (1-128, default 1): 1
First sector (34-468862094, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-468862094, default 468862094): 6143
Created partition 1


Command (m for help): n
Partition number (2-128, default 2): 2
First sector (34-468862094, default 6144): 
Last sector, +sectors or +size{K,M,G,T,P} (6144-468862094, default 468862094): 530431
Created partition 2


Command (m for help): n
Partition number (3-128, default 3): 3
First sector (34-468862094, default 530432): 
Last sector, +sectors or +size{K,M,G,T,P} (530432-468862094, default 468862094): 17307647
Created partition 3


Command (m for help): n
Partition number (4-128, default 4): 4
First sector (34-468862094, default 17307648): 
Last sector, +sectors or +size{K,M,G,T,P} (17307648-468862094, default 468862094): 468862094
Created partition 4


Command (m for help): t
Partition number (1-4, default 4): 1
Partition type (type L to list all types): 3
Changed type of partition 'Linux filesystem' to 'BIOS boot partition'

Command (m for help): t
Partition number (1-4, default 4): 2
Partition type (type L to list all types): 13
Changed type of partition 'Linux filesystem' to 'Linux RAID'

Command (m for help): t
Partition number (1-4, default 4): 3
Partition type (type L to list all types): 13
Changed type of partition 'Linux filesystem' to 'Linux RAID'

Command (m for help): t
Partition number (1-4, default 4): 4
Partition type (type L to list all types): 13
Changed type of partition 'Linux filesystem' to 'Linux RAID'

Command (m for help): p

Disk /dev/sdb: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt
Disk identifier: 2F21C828-C60E-4DBD-AC6B-DDA2B119B92D


#         Start          End    Size  Type            Name
 1         2048         6143      2M  BIOS boot parti 
 2         6144       530431    256M  Linux RAID      
 3       530432     17307647      8G  Linux RAID      
 4     17307648    468862094  215.3G  Linux RAID      

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


reboot hard node and list block devices:

lsblk 
NAME              MAJ:MIN    RM   SIZE RO TYPE  MOUNTPOINT
sda                 8:0       0 223.6G  0 disk  
├─sda1              8:1       0     2M  0 part  
├─sda2              8:2       0   256M  0 part  /boot
├─sda3              8:3       0     8G  0 part  [SWAP]
└─sda4              8:4       0 215.3G  0 part  /
sdb              8:16      0 223.6G  0 disk  
├─sdb1           8:17      0     2M  0 part  
├─sdb2           8:18      0   256M  0 part  
│ └─md0          9:0       0 255.7M  0 raid1 /boot
├─sdb3           8:19      0     8G  0 part  
│ └─md1          9:1       0     8G  0 raid1 [SWAP]
└─sdb4           8:20      0 215.3G  0 part  
  └─md2          9:2       0 215.2G  0 raid1 /
  

Now create raid :


mdadm --create /dev/md0 --level=1 --raid-devices=2 missing /dev/sdb2 
mdadm --create /dev/md1 --level=1 --raid-devices=2 missing /dev/sdb3 
mdadm --create /dev/md2 --level=1 --raid-devices=2 missing /dev/sdb4 


and make ext4 file system and swap:


mkfs.ext4 /dev/md0
mkfs.ext4 /dev/md2     
mkswap  /dev/md1

mount raid partitions and copy source and target :

mount /dev/md1 /mnt/
rsync -axu / /mnt/
mount /dev/md0 /mnt/boot/
rsync -axu /boot/ /mnt/boot/

Now mount and chroot :

mount --bind /proc/ /mnt/proc/
mount --bind /dev/ /mnt/dev/
mount --bind /sys/ /mnt/sys/
mount --bind /run/ /mnt/run/
 chroot /mnt/


Get blkid for md devices 

blkid | grep md
/dev/md1: UUID="68f122be-c9e3-4b55-ae59-140ba641ba57" TYPE="swap" 
/dev/md0: UUID="029cce04-6af9-49ac-b904-9c524e89af69" TYPE="ext4" 
/dev/md2: UUID="3f5bb96b-4803-49f8-aefc-f04f92586471" TYPE="ext4" 

and put it into /etc/fstab instead old's for / , /boot , swap


Create mdadm.conf :

mdadm --detail --scan > /etc/mdadm.conf


save current initrd and run dracut :

 mv /boot/initramfs-3.10.0-693.1.1.vz7.37.30.img /boot/initramfs-3.10.0-693.1.1.vz7.37.30.img.bak
 dracut /boot/initramfs-$(uname -r).img $(uname -r)

Add value  rd.auto=1 in /etc/default/grub to parameter GRUB_CMDLINE_LINUX:

GRUB_CMDLINE_LINUX="console=ttyS1,115200n8 crashkernel=auto console=ttyS1,115200n8,rd.auto=1"



Generate new grub.cfg 


grub2-mkconfig -o /boot/grub2/grub.cfg

and write new grub on both disks:

grub2-install /dev/sdb
grub2-install /dev/sda

exit from chroot and umount resources :

umount /mnt/run
umount /mnt/sys
umount /mnt/proc
umount /mnt/dev
umount /mnt/boot
umount /mnt 

Reboot hard node and change type partitions for /dev/sda like /dev/sdb :

fdisk -l /dev/sda
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt

#         Start          End    Size  Type            Name
 1         2048         6143      2M  BIOS boot parti BIOS
 2         6144       530431    256M  Linux RAID      BOOT
 3       530432     17307647      8G  Linux RAID      SWAP
 4     17307648    468862094  215.3G  Linux RAID      ROOT

fdisk -l /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdb: 240.1 GB, 240057409536 bytes, 468862128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: gpt

#         Start          End    Size  Type            Name
 1         2048         6143      2M  BIOS boot parti 
 2         6144       530431    256M  Linux RAID      
 3       530432     17307647      8G  Linux RAID      
 4     17307648    468862094  215.3G  Linux RAID  

Then add sdaX partition to raid :
mdadm --manage /dev/md0 --add /dev/sda2
mdadm --manage /dev/md1 --add /dev/sda3
mdadm --manage /dev/md2 --add /dev/sda4


понедельник, 1 августа 2016 г.

Generate self-signed wildcard ssl certificate

 $ openssl genrsa 2048 > domain.key
Generating RSA private key, 2048 bit long modulus
........+++
..................................+++
e is 65537 (0x10001)
$ openssl req -new -x509 -nodes -sha1 -days 365 -key domain.key > domain.crt
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:UA
State or Province Name (full name) [Some-State]:Kiev
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:company
Organizational Unit Name (eg, section) []:operations
Common Name (e.g. server FQDN or YOUR name) []:*.domain.name.com
Email Address []:operations@gmail.com
$ls -al
domain.crt
domain.key

Now you can put these files to your nginx/apache and configure servers.

воскресенье, 27 марта 2016 г.

How to configure fail2ban to defence Wordpress xmlrpc.php from DDOS attack



Install fail2ban package:

yum install -y fail2ban
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
vi /etc/fail2ban/jail.local

add to end of file next section:
[xmlrpc]
enabled = true
filter = xmlrpc
action = iptables[name=xmlrpc, port=http, protocol=tcp]
logpath = /var/log/{nginx,apache}/access.log
bantime = 3600
maxretry = 3

Then go to filter.d directory :

 cd /etc/fail2ban/filter.d/
and create  xmlrpc.conf file with next content:


[Definition]
failregex = ^<HOST> .*POST .*xmlrpc\.php.*
ignoreregex =


restart fail2ban service:

service fail2ban restart

and see fail2ban log :

tail -f /var/log/fail2ban.log

fail2ban.jail            : INFO    Jail 'xmlrpc' uses poller
fail2ban.filter         : INFO    Set jail log file encoding to UTF-8
fail2ban.jail            : INFO    Initiated 'polling' backend
fail2ban.filter         : INFO    Added logfile = /var/log/nginx/access.log
fail2ban.filter         : INFO    Set maxRetry = 2
fail2ban.filter         : INFO    Set jail log file encoding to UTF-8
fail2ban.actions     : INFO    Set banTime = 43600
fail2ban.filter         : INFO    Set findtime = 600
fail2ban.jail            : INFO    Jail 'xmlrpc' started
fail2ban.filter         : INFO    [xmlrpc] Found 208.67.y.xx
fail2ban.filter         : INFO    [xmlrpc] Found 46.161.y.xxx

fail2ban.actions     :WARNING [xmlrpc] Ban 5.39.88.106