Operations 3 min read

Resolving Nginx 502 Bad Gateway Errors with SSL Handshake Issues and Buffer Configuration

This article analyzes 502 Bad Gateway errors caused by SSL handshake failures in Nginx, presents the relevant error logs and curl output, and provides a detailed configuration example—including buffer sizes, client limits, and proxy settings—to fix the issue.

Practical DevOps Architecture
Practical DevOps Architecture
Practical DevOps Architecture
Resolving Nginx 502 Bad Gateway Errors with SSL Handshake Issues and Buffer Configuration

The server returned a 502 Bad Gateway response when accessing http://192.168.20.69 , with error logs showing SSL handshake failures and "peer closed connection" messages such as 2022/02/24 10:12:49 [error] 20021#0: *44 peer closed connection in SSL handshake (104: Connection reset by peer) .

A quick curl test ( curl -I http://192.168.20.69 ) confirmed the problem, returning HTTP/1.1 502 Bad Gateway along with standard Nginx headers.

The original nginx.conf contains basic settings (user, worker_processes, events, etc.) and a server block listening on port 80 that proxies requests to https://nuget.cdn.azure.cn/v3/index.json . To address the errors, the configuration was updated with larger buffers and timeouts:

client_max_body_size 1024m; client_body_buffer_size 10m; client_header_buffer_size 10m; proxy_buffers 4 128k; proxy_busy_buffers_size 128k; gzip on;

The server block now includes:

listen 80; server_name 192.168.20.69; location / { root html; index index.html index.htm; proxy_pass https://nuget.cdn.azure.cn/v3/index.json; }

Additional includes ( include sub/*.conf; and include to_internet/*.conf; ) remain unchanged. After applying these settings, the SSL handshake succeeds and the 502 error is resolved.

backendoperationsconfigurationnginxSSL handshake502 Bad Gateway
Practical DevOps Architecture
Written by

Practical DevOps Architecture

Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.