Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure AD WebApp behind reverse proxy receives 502 Bad Gateway

I have an ASP.NET Core app running on a server behind a nginx reverse proxy.

The reverse proxy forwards xxx.mydomain.com to https://localhost:5000. If I use Azure AD for authentication I get a 502 Bad Gateway after the sign in procedure. The callback path seems correct /signin-oidc. I added the full address to the portal.

EDIT: I was able to get the nginx log from the server and I get the following error:

2017/03/05 22:13:20 [error] 20059#20059: *635 upstream sent too big header 
while reading response header from upstream, client: xx.xx.xxx.xxx, server: 
xxx.mydomain.com, request: "POST /signin-oidc HTTP/1.1", upstream: 
"https://192.168.3.20:5566/signin-oidc", host: "xxx.mydomain.com", referrer: 
"https://login.microsoftonline.com/5712e004-887f-4c52-8fa1-
fcc61882e0f9/oauth2/authorize?client_id=37b8827d-c501-4b03-b86a-
7eb69ddf9a8d&redirect_uri=https%3A%2F%2...ch%2Fsignin-
oidc&response_type=code%20id_token&scope=openid%20profile&response_mode=form_pos
t&nonce=636243452000653500.NzRjYmY2ZTMtOTcyZS00N2FlLTg5NGQtMTYzMDJi..."

As I read in many other posts I tried to update the buffer sizes etc. but that all didn't work.

I am out of ideas where to look. Any ideas?

like image 899
Matteo Avatar asked Oct 28 '25 14:10

Matteo


1 Answers

To answer this question it was the buffer size set in the nginx reverse proxy.

The problem was that i was running this on my synology and after every reboot the nginx settings will be reset. So what I ended up doing is write a small bash script that was run after the reboot and copied back my edited settings and restarted the reverse proxy.

like image 191
Matteo Avatar answered Oct 31 '25 12:10

Matteo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!