NGINX AND MY SPRING BOOT APP STOPPED TALKING TO EACH OTHER AFTER A REBOOT. WHY?

502nginxreverse-proxy5 replies · 210 views · started
  1. hmmmm ok this one is driving me crazy. after a reboot, a chunk of requests fail with this page:

    502 Bad Gateway

    502 Bad Gateway
    nginx
    

    not all of them, maybe one in ten, the Spring Boot app health check is green the whole time, my manager asked if we turned it off and on again. we did... several times.

    load is not crazy, a few hundred requests a minute at peak lmao id realy like to understand what nginx is complaining about before I start randomly changing timeouts and buffer sizes and make things worse. thx in advance!!

    15
  2. hmmm what exactly does /var/log/nginx/error.log say at the moment of a 502? ??

    3 0 helpful
  3. sorry forgot to say under load i see upstream prematurely closed connection while reading response header. never noticed it before.

    8 0 helpful
  4. ahh classic large response headers (big cookies, JWTs) can produce upstream sent too big header. bump proxy_buffer_size 16k; and proxy_buffers 8 16k; and reload.

    5 0 helpful
  5. oh ive been there lol if it only happens under load or intermittently, look at keepalive mismatch. if the app closes idle connections sooner than nginx reuses them, you get sporadic 502s... either raise the apps keep-alive tmieout above nginxs, or set proxy_http_version 1.1; with proxy_set_header Connection ""; and a sensible keepalive in the upstream block.

    8 2 helpful
  6. hmmmm not sure about that before tuning keepalive Id check whetehr the app is simply running out of workers. A 502 under load is often an overwhelmed backend, not a proxy issue. idk maybe im wrong lol

    2 2 helpful

Reply to this topic

Sign in or create an account to reply.