AWS单实例Tomcat SSL

时间:2014-10-24 02:37:36

标签: java tomcat ssl amazon-web-services amazon-ec2

我正在尝试在我的EC2 tomcat实例上设置4月SSL连接器,但它不起作用,我不知道为什么。

我有有效的证书和公钥文件。已安装Apr模块,我已将端口8443添加到我的EC2实例的安全组,但是当我尝试访问链接https://myapp-env.elasticbeanstalk.com:8443/时,该页面不可用。

我已将以下配置添加到tomcat的server.xml中:

<Connector 
    port="8443" 
    protocol="org.apache.coyote.http11.Http11AprProtocol"
    maxThreads="200" 
    scheme="https" 
    secure="true"
    SSLEnabled="true" 
    SSLCertificateFile="/etc/ssl/certs/myapp.crt" 
    SSLCertificateKeyFile="/etc/ssl/certs/myapp.key"
    clientAuth="optional" 
    sslProtocol="TLSv1" />

Tomcat的日志没有显示任何错误消息,恰恰相反:

Oct 24, 2014 1:51:50 AM org.apache.catalina.core.AprLifecycleListener initializeSSL
INFO: OpenSSL successfully initialized (OpenSSL 1.0.1h 5 Jun 2014)
Oct 24, 2014 1:51:50 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler "http-apr-8080"
Oct 24, 2014 1:51:51 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler "ajp-apr-8009"
Oct 24, 2014 1:51:51 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler "http-apr-8443"
Oct 24, 2014 1:51:51 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 2083 ms
Oct 24, 2014 1:51:51 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 24, 2014 1:51:51 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.55

我错过了什么?提前谢谢。

Port 8443 added to security group

1 个答案:

答案 0 :(得分:1)

它实际上比我想象的容易,更容易!我在以下网址找到了相应的文档:

http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/ssl-server-cert.html

简而言之,在Linux AMI中拥有证书和私钥,您必须运行以下命令:

sudo yum install apr.i686
sudo yum install mod_ssl
sudo yum install tomcat-native.x86_64
aws configure (enter your aws account data here)
aws iam upload-server-certificate --server-certificate-name yourAliasHere --certificate-body file://certificate.crt.pem --private-key file://private.key.pem

必须使用file://表示法。之后,只需转到您的Elastic Beanstalk,配置,负载平衡,然后设置Secure listener portSSL certificate ID(您刚刚上传的)字段,然后保存。

enter image description here