Websites show 502 Bad Gateway after enabling nginx on a server with Fail2ban

Created:

2016-12-12 03:45:12 UTC

Modified:

2017-08-15 10:49:35 UTC

30

Was this article helpful?


Have more questions?

Submit a request

Websites show 502 Bad Gateway after enabling nginx on a server with Fail2ban

Applicable to:

  • Plesk 12.5 for Linux
  • Plesk Onyx for Linux
  • Plesk 12.0 for Linux

Symptoms

  1. nginx as a proxy is enabled for a server.
  2. Websites are periodically down with the following error from nginx:

    502 Bad Gateway
  3. The following errors can be found in /var/www/vhosts/system/example.com/logs/proxy_error_log:

    CONFIG_TEXT: [error] 10485#0: *1947668 connect() failed (111: Connection refused) while connecting to upstream, client: 203.0.113.2, server: , request: "GET / HTTP/1.1", upstream: "http://192.0.2.2:7080/", host: "example.com"

    Where 192.0.2.2 is server's IP address.

Cause

Fail2Ban blocks server's IP addresses.

Resolution

  1. In Plesk > Tools & Settings > IP Addresses click Re-read IP button.
  2. Add all server IP addresses to Trusted IP Addresses list in Fail2ban configuration under Tools & Settings > IP Address Banning (Fail2Ban).
  3. If the issue persits, connect to the server using SSH and restart 'iptables' service:
    # service iptables restart
Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    Olosz Andor

    This solution is worked for me (Plesk 17.0.17)

    Thank you! :)

  • 0
    Avatar
    iamkingsleyf

    did not help

  • 0
    Avatar
    Pavel Mikhaylov

    Hello iamkingsleyf,

    Could you clarify a few moments, please:

    1. Did the symptoms match entirely to ones you were having? 502 error is quite general and solutions may vary, depending on the additional symptoms.
    2. Does the issue still persist or did you manage to resolve it by other means?

    If the issue is not resolved, I would like to recommend to contact our support: https://www.plesk.com/contact-support

Please sign in to leave a comment.