This article is a mirror article of machine translation, please click here to jump to the original article.

View: 14033|Reply: 0

Alibaba Cloud SLB Load Balancing Solution for 502 Bad Gateway Gateway Error

[Copy link]
Posted on 8/13/2019 2:42:43 PM | | | |
I have been using Alibaba Cloud SLB load balancer for more than 5 years, and I have been using it since the initial Alibaba Cloud internal beta, and after deployment, the following error occurred:



502 Bad Gateway

Errors occur intermittently, after initially booting, there is no 502 gateway error, after waiting for a minute, the error appears, the backend Windows Server IIS container ASP.NET website.

Click IIS from the server to open the browser, you can browse normally, SLB load balancing indirect problems, this is the first time I have encountered it.

Solution:

The problem mainly appears in the "Health Check Method" settings, the default settings are as follows:



The backend health check is requested in the head way, and if the corresponding status code returns 2xx or 3xx, the backend server is considered normal.

We tried to make a header request in three ways, first, I directly ran the local project and tested it locally.

Test 1:

Use the postman test as shown below:



Returning to the 404 Not Found state, in fact, here, we know what caused it.

Test 2:

Use curl testing as shown below:

Windows (64-bit) download using the curl command with the tool
https://www.itsvse.com/thread-3409-1-1.html
(Source: Architect_Programmer)
C:\Users\itsvse>curl -i -X HEAD http://localhost:60155/
Warning: Setting custom HTTP method to HEAD with -X/--request may not work the
Warning: way you want. Consider using -I/--head instead.
HTTP/1.1 404 Not Found
Cache-Control: private
Content-Length: 4432
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/10.0
X-SourceFiles: =?UTF-8?B?QzpccHJvamVjdFxteVxDb2RlU2hhcmluZ1xDb2RlU2hhcmluZy5XZWJVSVxIb21lXEVycm9yNDA0?=
X-Powered-By: ASP.NET
Date: Tue, 13 Aug 2019 03:53:04 GMT

curl: (56) Recv failure: Connection was reset



Also returned is a 404 status code.

Test 3:

This time, we tested directly on the official server, through the curl test under PowerShell, as shown in the figure below:



You can see that the same page is requested through the head,Sometimes return404status code, sometimes returned200Status code, thus confirming the intermittent 502 errors we encountered at the beginning.

What causes asp.net intermittently returning 404 and 200 status codes?

Since our homepage has a cache, when the user uses the get method to request the homepage, the page will be cached successfully, and then the head and get will always return the cached page, and will also return the 200 response code, if, after the cache expires, no user makes a get method request, only the head method request through the command, a 404 error will occur. It is estimated that few people will encounter this kind of problem.

The solution is to check all response status codes in the health check mode, as shown in the figure below:



How to troubleshoot Layer 7 Listening (HTTP/HTTPS) health check abnormalities:The hyperlink login is visible.

(End)




Previous:Considerations for using Amazon AWS CloudFront
Next:Day 76 in Shenzhen
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com