在EC2 Ubuntu实例上安装COMODO EV SSL证书



提前感谢您的帮助。

这是我第一次设置HTTPS,我刚从Comodo获得证书,但不知道该怎么办。证书在一个.zip文件中,里面有这些文件:

Root CA Certificate - AddTrustExternalCARoot.crt
Intermediate CA Certificate - COMODOAddTrustServerCA.crt
Intermediate CA Certificate - COMODOExtendedValidationSecureServerCA.crt
Your COMODO EV SSL Certificate - forum_linma_com.crt

我也有它的文本格式。我如何设置它,使我的node.js应用程序可以通过HTTPS访问?该应用程序运行在带有Ubuntu 13.10的EC2实例上,我使用SSH访问服务器。

后续问题

所以我还是犯了一个错误。以下是相关信息:

/etc/apache2/sites-enabled/forumHTTPSconfig(站点中唯一启用的文件)的内容:

<VirtualHost *:443>
ServerName forum.figma.com
SSLEnable
SSLEngine on
SSLCertificateFile /etc/apache2/forum_figma_com.crt
SSLCertificateKeyFile /home/ubuntu/.ssh/myserver.key
SSLCACertificateFile /etc/apache2/combined-ca.crt
</VirtualHost>
<IfModule mod_proxy.c>
<Proxy *>
SSLProxyEngine on
Order deny,allow
Allow from all
</Proxy>
RewriteEngine on
ProxyPass / https://127.0.0.1:3000
ProxyPassReverse /http://127.0.0.1:3000
</IfModule>

以下是我尝试调用a2enmod:的输出

ubuntu@ip-10-190-91-217:/etc/apache2/sites-enabled$ sudo a2enmod forumHTTPSconfig
ERROR: Module forumHTTPSconfig does not exist!
ubuntu@ip-10-190-91-217:/etc/apache2/sites-enabled$ sudo a2enmod mywebsite
ERROR: Module mywebsite does not exist!

知道出了什么问题吗?提前感谢您的帮助!

首先,请记住有一个私有的key文件,您最初用来生成证书。您的配置中需要它。

  1. 设置它的一种方法是在node.js应用程序上配置HTTPS。您可以在这里找到更多信息:

    http://nodejs.org/docs/latest/api/https.html

  2. 另一种设置方法是使用apache或nginx为node.js应用程序设置反向代理。

nginx

抓取所有文件:

Root CA Certificate - AddTrustExternalCARoot.crt
Intermediate CA Certificate - COMODOAddTrustServerCA.crt
Intermediate CA Certificate - COMODOExtendedValidationSecureServerCA.crt
Your COMODO EV SSL Certificate - forum_linma_com.crt

并将它们的所有内容连接到forum_linma_cm.crt 中

下面是一个示例配置:

server {
listen       443;
server_name  yourdomain.com;
ssl                  on;
ssl_certificate      /path/to/forum_linma_com.crt;
ssl_certificate_key  /path/to/forum_linma_com.key;
location / {
proxy_pass  http://localhost:3000;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header        Host            static.example.com;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

以下是nginx和反向代理的更多信息:

http://wiki.nginx.org/HttpProxyModule

Apache

获取以下内容:

Root CA Certificate - AddTrustExternalCARoot.crt
Intermediate CA Certificate - COMODOAddTrustServerCA.crt
Intermediate CA Certificate - COMODOExtendedValidationSecureServerCA.crt

并将它们的所有内容连接到一个文件中:combined-ca.crt

这是一个示例配置:

<VirtualHost 0.0.0.0:443>
ServerName mydomain.com
SSLEnable
SSLEngine on
SSLCertificateFile /path/to/forum_linma_com.crt
SSLCertificateKeyFile /path/to/forum_linma_com.key  
SSLCACertificateFile /path/to/combined-ca.crt
<IfModule mod_proxy.c>
<Proxy *>
SSLProxyEngine on
Order deny,allow
Allow from all
</Proxy>
RewriteEngine on
ProxyPass / https://127.0.0.1:3000
ProxyPassReverse /http://127.0.0.1:3000
</IfModule>
</VirtualHost>

3000是node.js服务器运行的端口。

以下是Apache和反向代理的更多信息:

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

这只是@AaronClayton Dunn的澄清。

我应该在apache2.conf的末尾添加示例配置吗?

由于您使用的是Ubuntu,通常的过程是创建一个文件:/etc/apache2/sites-enabled/mywebsite并将示例内容放在那里。

要启用它,您可以运行:

sudo a2dismod default
sudo a2enmod mywebsite
sudo service apache2 restart

它真的应该是0.0.0.0:443吗?还是我应该输入实际的IP地址?

您可以使用0.0.0.0或*(星号),这基本上告诉它监听服务器上的任何地址。无需放置特定的IP地址,除非您想限制对web服务器的访问,这意味着客户端必须使用特定的IP IP地址才能连接到您的服务器。

我应该更改另外两个地址(ProxyPass、ProxyPassReverse)吗?

否。这些语句基本上是说将所有进入站点上端口443的/的内容转发到HTTP端口3000,这是node.js服务器应该运行的地方。

最新更新