大网数据广告活动
服务器运维问答

AWS - our site throws a 502 when we use our certificate

· 52CE 我爱测

We're having a problem where we can't access our site over HTTPS when using a valid certificate. We have a domain, registered in Route53, and a certificate. We have a load balancer: our-production-elb-1234567.eu-west-2.elb.amazon…

问题原文

原帖链接 · jackdaw · CC BY-SA 4.0

We're having a problem where we can't access our site over HTTPS when using a valid certificate.

We have a domain, registered in Route53, and a certificate.

We have a load balancer:

our-production-elb-1234567.eu-west-2.elb.amazonaws.com

We have two target groups, with targets managed by ECS:

our-production-target-group-https
our-production-target-group-http

We have two listeners on the load balancer:

HTTP : 80, forwarding to our-production-target-group-http
HTTPS : 443, forwarding to our-production-target-group-https

We have a certificate applied to the https listener:

ouractualdomain.com
*.ouractualdomain.com

I have run logs on the actual instance, http requests get through fine whereas https requests don't show at all.

When I use the real certificate for the https listener, I get a 502 error. If I use a self-signed certificate it works fine with a security warning in chrome.

Does anyone have any ideas what could be happening?

Thanks!

已采纳解答

原帖链接 · KayD · CC BY-SA 4.0

Cloud Front If the domain names don't match, the SSL/TLS handshake fails, and CloudFront returns an HTTP status code 502 (Bad Gateway) and sets the X-Cache header to Error from CloudFront.

To determine whether domain names in the certificate match the Origin Domain Name in the distribution or the Host header, you can use an online SSL checker or OpenSSL. If the domain names don't match, you have two options:

  1. Get a new SSL/TLS certificate that includes the applicable domain names.
  2. Change the distribution configuration so CloudFront no longer tries to use SSL to connect with your origin.

Load balancer HTTP 502 (bad gateway) errors can occur for one of the following reasons:

  1. The web server or associated backend application servers running on EC2 instances return a message that can't be parsed by your Classic Load Balancer.

  2. The web server or associated backend application servers return a 502 error message of their own.

To find the source of these 502 errors:

  1. Enable ELB access logs on your Classic Load Balancer to see the backend and Elastic Load Balancing (ELB) response code for each request. An access log entry contains two fields: an elb_status_code and a backend_status_code. Use these codes to determine the source of the 502 error.
  2. View the load balancer CloudWatch metrics to see backend-generated 502 errors, which appear under the HTTPCode_Backend_5XX metric. ELB-generated 502 errors appear under the HTTPCode_ELB_5XX metric.

If the backend response is the source of the ELB 502 error, the issue might be caused by:

  1. A response containing more than one CRLF between each header.
  2. A response containing a Content-Length header that contains a non-integer.
  3. A response has more bytes in the body than the Content-Length header value.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-07-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。