【发布时间】:2018-02-24 02:04:37
【问题描述】:
这是我的情况:
我正在使用 Elastic Beanstalk 来启动没有 ELB 的单个 EC2 实例。我想让实例只能通过 API 网关访问。所以,我选择了使用客户端证书进行身份验证,就像here 中描述的那样。
我的 EC2 实例有 Nginx 为 Rails 应用程序提供服务。我在我的机器上生成了一个自签名证书并将 Nginx 配置为使用它通过 https 提供内容。
一切似乎都很好,但是当我尝试从 API Gateway 控制台调用我的代理端点时,我收到一个 500 错误,如下所示:
...
Thu Sep 14 02:27:05 UTC 2017 : Endpoint request URI: https://xxxxxxxxx.xxxxxxxxx.us-east-1.elasticbeanstalk.com/health
Thu Sep 14 02:27:05 UTC 2017 : Endpoint request headers: {x-amzn-apigateway-api-id=xxxxxxxxx, User-Agent=AmazonAPIGateway_xxxxxxxx, Accept-Encoding=identity}
Thu Sep 14 02:27:05 UTC 2017 : Endpoint request body after transformations:
Thu Sep 14 02:27:05 UTC 2017 : Sending request to https://xxxxxxxxx.xxxxxxxx.us-east-1.elasticbeanstalk.com/health
Thu Sep 14 02:27:05 UTC 2017 : Execution failed due to configuration error: General SSLEngine problem
Thu Sep 14 02:27:05 UTC 2017 : Method completed with status: 500
我认为这与我在后端使用自签名证书这一事实有关。但是我真的必须购买合法证书才能完成我的设置吗?是否有任何其他解决方案允许我仅通过 API 网关接受对我的 EC2 实例的请求?
我查看了here 中描述的 Lambda 方法,但我不想为请求增加任何复杂性或延迟。
为了完整起见,这是我的 Nginx 配置:
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate /etc/pki/tls/certs/server.crt;
ssl_certificate_key /etc/pki/tls/certs/server.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_prefer_server_ciphers on;
ssl_client_certificate /etc/pki/tls/certs/api_gateway.cer;
ssl_verify_client on;
if ($ssl_protocol = "") {
return 444;
}
}
【问题讨论】:
标签: ruby-on-rails amazon-web-services ssl nginx aws-api-gateway