Azure Application Gateway : Debugging the dreadful “502”-error

Introduction

When you set up your Application Gateway on Azure, and you’re getting the following message…

2016-10-16-20_01_59-502-web-server-received-an-invalid-response-while-acting-as-a-gateway-or-proxy

Then you know you are in a world of pain in order to debug this. So before we continue, please help to avoid this pain by voting on the user voice! 😉

 

The Basics

When we take a look at the documentation, then we see how the logic works… Basically it will do a GET of the following url on each node ; http://127.0.0.1:/. The (healthy) response should be a status code between 200 and 399.

Apart from that, once you have created the application gateway. You’re back-end pool will be empty. So the first thing to check is if you’ve already added your nodes.

 

Example Troubleshooting : Rancher node shown as down

After cursing for a while, I did a network trace to see what was happening. As my host was an Ubuntu (Linux), I used tcpdump ;

tcpdump port 80

2016-10-16-20_02_37-rootkvaes-rancher-mgmt01_

As you can see from the output, there is a “401 Unauthorized” error code. We just learned that the response should be between 200 and 399, so we’re 2 short of a good status.

 

So how to fix this? Let’s create a custom node…

2016-10-16-20_05_06-origin

Why change to this?

2016-10-16-20_25_36-rootkvaes-rancher-mgmt01_

Because loading the /login/ page will get you a 200 or 304 (depending on the previous sequence). These values reside between 200 and 399, so we’re good!

Advertisements

One thought on “Azure Application Gateway : Debugging the dreadful “502”-error

  1. Thanks a bunch. I was accessing web service page which actually returns the default “See help page” but with code 404. So I just used the help page as probe by following your instructions and it worked!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s