Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

488
Visualizações
How to properly set nginx timeouts as proxy?

I am getting a few 502 errors in nginx:

2020/05/05 20:40:05 [error] 13425#0: *1360447 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 172.31.12.13, server: , request: "POST /app/functionHTTP/1.1", upstream: "http://127.0.0.1:8080/app/function", host: "example.com"

Architecture:

client - load balancer - instances (each with nginx proxy for NodeJS http server)

Timeout values:

  • client:

    • request timeout: 60s
  • load balancer:

    • keepalive timeout: 60s
  • nginx:

    • http keepalive_timeout: 65s
    • upstream keepalive_timeout: 60s
    • upstream keepalive: 256 connections
    • proxy_connect_timeout: 60s
    • proxy_read_timeout: 60s
    • proxy_send_timeout: 60s
  • server (NodeJS):

    • request timeout: 50s
    • keepAliveTimeout: 65s
    • headersTimeout: 70s

The 502 errors occur rarely (~0.01% of requests) but consistently.

What I've checked so far:

  • Limit of file descriptors not reached
  • Limit of nginx connections not reached
  • Limit of TCP ports not reached
  • Limit of CPU, memory, disk I/O not reached

It looks much like a race condition where the NodeJS server closed the connection and nginx is assuming the connection still exists.

What would be proper nginx timeout values in the current setting?

(I am unsure whether this isn't rather a question for ServerFault?)

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda