Posts

Showing posts from August, 2021

AWS Load Balancer return 502/504 Error & (possible) solution

Are you facing a 502 Bad Gateway problem from your AWS load balancer, while your web server return value successfully? If so, please read on. Here is my situation: - I am using Wordpress 5.8 as backend service - In WP admin panel we create a PHP function that make an AJAX request, which then called another WP functions, and get JSON string as return. - But this WP admin panel is behind an AWS Load balancer, which means the URL points to AWS LB first, and the values will be transferred back-and-forth between LB - WP. Here is the problem:  When we make an AJAX request, LB returns 502 Bad Gateway in our testing server.  But there is no problem in local development server. Here is why this problem exists: - First of all, this is NOT a timeout problem.   - We tested that web server can handle up to 2 mins long request.  But even if the request just use 7 seconds, it will still return 502.  So setting Keep-alive(timeout) and other server timeout did not work. https://medium.com/jalexs-murmur