Nginx Reverse Proxy – 502 Bad Gateway

Spread the love

If your service (url) is accessible and all need headers set but nginx returned 502 error – try to enable SNI. It can be very actual for reverse proxy AWS services (API Gateway, CloudFront and etc)

For the fix, try to enable proxy_ssl_server_name in the location section


proxy_ssl_server_name on;

Sample of configuration (for reverse proxy for AWS CloudFront):

location / {
    proxy_ssl_protocols TLSv1.2;
    proxy_ssl_server_name on;

Leave a Reply