SOLVED Sucuri and 502 Bad Gateway for Dns issue?

dexter009

Registered
Jun 3, 2017
2
0
1
Rome
cPanel Access Level
Root Administrator
Hi guys,

I have a strange problem, on a working domain and hosting we changed the dns setting pointing it to the sucuri waf ip and from that moment we are getting 502 bad gateway from nginx.

I think the problem is related to the nginx dns query that return a different ip respect the cpanel one (the sucuri ip), could be?

Any experience on it or what fix it?

Thank you
Regards
Marco
 

Jcats

Well-Known Member
PartnerNOC
May 25, 2011
807
158
168
New Jersey
cPanel Access Level
DataCenter Provider
Marco,

Is the 502 bad gateway being thrown by Sucuri, or are you saying you have Nginx installed on your server?
 

dexter009

Registered
Jun 3, 2017
2
0
1
Rome
cPanel Access Level
Root Administrator
Hi,

Yes, the error was coming out from my server that is running a classical setup nginx+apache.

After many hours looking on google i have found the reason of this, the resolver option under the nginx configuration was performing a dns query to each domain before to pass the request to apache trying to connect to the sucuriIP:8080 that's the reason of the 502 error.

The workaround has been to replace the google dns 8.8.8.8 used with the local bind server.

Probably there is a better way to do this, but it's working fine.

Thank you
M.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,904
2,218
463
Hello,

I'm happy to see you were able to address the issue. Thank you for updating us with the outcome.