大网数据广告活动
服务器运维问答

Can't start fail2ban on Nginx-Apache server

· 52CE 我爱测

As my host and I are at an impasse, I thought I’d reach out for a bit of help. I’m trying to wrap my head around this stuff and not sure how to proceed. I have a VPS account and host a few WP sites for clients. Server info: Nginx…

问题原文

原帖链接 · popvid · CC BY-SA 4.0

As my host and I are at an impasse, I thought I’d reach out for a bit of help. I’m trying to wrap my head around this stuff and not sure how to proceed.

I have a VPS account and host a few WP sites for clients. Server info: Nginx (1.17.0) – Apache (2.4.39) on CentOS 7.6.

After recently reading about the strengths of fail2ban I decided to give it a try (ie, f2b with the WP plugin). I asked the hosting company to install f2b and they did so a couple of days ago. Unfortunately, I’ve not been able to get it off the ground at all and they’re not willing to help unless I give them some coin.

They installed v 0.9.7, although the current version appears to be 0.10.4. Following instructions from the following guides and docs:
- https://www.digitalocean.com/community/tutorials/how-to-protect-ssh-with-fail2ban-on-centos-7
- https://www.howtoforge.com/tutorial/how-to-install-fail2ban-on-centos/
- https://docs.wp-fail2ban.com/en/4.2/introduction.html

I installed the plugin, and performed the following:

  1. confirmed that /wp-content/plugins/wp-fail2ban/filters.d/ contained wordpress-hard.conf, wordpress-soft.conf, and wordpress-extra.conf (as listed in the docs)

  2. sudo systemctl enable fail2ban = no error

  3. I created the jail.local file and placed the following code inside:

    [DEFAULT]

    ## ban hosts for one hour:
    bantime = 3600

    ## override /etc/fail2ban/jail.d/00-firewalld.conf:
    banaction = iptables-multiport

    [sshd]
    enabled = true

    [wordpress-hard]
    enabled = true
    filter = wordpress-hard
    logpath = /var/log/auth.log
    maxretry = 1
    port = http,https

    [wordpress-soft]
    enabled = true
    filter = wordpress-soft
    logpath = /var/log/auth.log
    maxretry = 3
    port = http,https

– exited nano and saved
  1. sudo systemctl restart fail2ban resulted in the following:
    Job for fail2ban.service failed because the control process exited with error code. See “systemctl status fail2ban.service” and “journalctl -xe” for details.

  2. systemctl status fail2ban.service resulted in:

fail2ban.service – Fail2Ban Service Loaded: loaded   (/usr/lib/systemd/system/fail2ban.service; enabled; vendor preset: disabled)  
Active: failed (Result: start-limit) since Mon 2019-08-05 14:52:20 EDT; 1min 4s ago Docs: man:fail2ban(1)  
Process: 12326 ExecStart=/usr/bin/fail2ban-client -x start (code=exited, status=255)  
Main PID: 9099 (code=exited, status=0/SUCCESS)
  1. sudo fail2ban-client status resulted in:
ERROR Failed to access socket path: /var/run/fail2ban/fail2ban.sock. Is fail2ban running?
  1. After seeing the above, I looked for /var/run/fail2ban/fail2ban.sock. The file is missing/not there/nonexistent.

  2. journalctl -u fail2ban.service results in:

fail2ban-client[10992]: ERROR Errors in jail ‘wordpress-hard’. Skipping…  
fail2ban-client[10992]: ERROR Found no accessible config files for ‘filter.d/wo  
fail2ban-client[10992]: ERROR No section: ‘Definition’  
fail2ban-client[10992]: ERROR No section: ‘Definition’  
fail2ban-client[10992]: ERROR Unable to read the filter

And that’s where I’m at. Did I do something wrong? Did they do something wrong? How to fix? Thanks and My apologies for the length.

已采纳解答

原帖链接 · Khimananda Oli · CC BY-SA 4.0

You forget to copy conf to /etc/fail2ban/filter.d/

e.g
sudo cp /var/www/html/wp-content/plugins/wp-fail2ban/filters.d/wordpress-hard.conf /etc/fail2ban/filter.d/

also do not forgot to copy wordpress-soft.conf to filters.d direcotry

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。