Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS EC2&x2B;Nginx+;SSL fro子域_Amazon Web Services_Ssl_Amazon Ec2_Ssl Certificate - Fatal编程技术网

Amazon web services AWS EC2&x2B;Nginx+;SSL fro子域

Amazon web services AWS EC2&x2B;Nginx+;SSL fro子域,amazon-web-services,ssl,amazon-ec2,ssl-certificate,Amazon Web Services,Ssl,Amazon Ec2,Ssl Certificate,有人能给我解释一下如何在我的AWS EC2上安装SSL吗。我读了很多文章,说这些步骤很简单,但我尝试了其中的两个步骤,但都不起作用 我有一个AWS EC2 EC2 staic ip,54.X.X.X subdoamin,xxxx.ab.abc.com 安全组:来自的端口 定制804439000-9100 nginx重定向 aaa1.ab.abc.com:80至aaa1.ab.abc.com:9001 aaa2.ab.abc.com:80至aaa1.ab.abc.com:9002 aaa3.ab.

有人能给我解释一下如何在我的AWS EC2上安装SSL吗。我读了很多文章,说这些步骤很简单,但我尝试了其中的两个步骤,但都不起作用

我有一个AWS EC2

EC2 staic ip,54.X.X.X
subdoamin,xxxx.ab.abc.com
安全组:来自的端口
定制804439000-9100
nginx重定向
aaa1.ab.abc.com:80至aaa1.ab.abc.com:9001
aaa2.ab.abc.com:80至aaa1.ab.abc.com:9002
aaa3.ab.abc.com:80至aaa1.ab.abc.com:9003

aaa(n).ab.abc.com:80至aaa1.ab.abc.com:900(n)

ngnix.conf
服务器{
听80;
服务器名称(aaa(?[0-9]+).ab.abc.com;
地点/{
设置$custom_port 90$站点;
如果($custom_port~“^.{3}$”){
设置$custom_port 900$站点;
}
proxy_http_版本1.1;
代理设置头升级$http\U升级;
代理设置头连接“升级”;
代理设置头主机$Host;
代理通行证http://127.0.0.1:$海关港口;
}
}
如何将SSL安装到EC2中,这样无论我访问哪个子域。它会得到认证吗

Steps I have done.

$sudo service nginx stop
$git clone https://github.com/certbot/certbot.git to use certbot to generate SSL key
$./certbot-auto certonly --manual --email test@gmail.com -d ab.abc.com
$mkdir -p /tmp/certbot/public_html/.well-known/acme-challenge
$cd /tmp/certbot/public_html
$printf "%s" <key> > .well-known/acme-challenge/<key>
$sudo $(command -v python2 || command -v python2.7 || command -v python2.6) -c "import BaseHTTPServer, SimpleHTTPServer; s=BaseHTTPServer.HTTPServer(('', 80), SimpleHTTPServer.SimpleHTTPRequestHandler);s.serve_forever()"

then I have

108.14.0.213 - - [09/Jul/2017 03:32:26] "GET /path? HTTP/1.1" 404 -
^CTraceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/SocketServer.py", line 236, in serve_forever
    poll_interval)
  File "/usr/lib/python2.7/SocketServer.py", line 155, in _eintr_retry
    return func(*args)
KeyboardInterrupt
我已完成的步骤。
$sudo服务nginx站
$git克隆https://github.com/certbot/certbot.git 使用certbot生成SSL密钥
$./certbot仅自动证书--手动--电子邮件test@gmail.com-d ab.abc.com
$mkdir-p/tmp/certbot/public_html/。著名的/acme挑战
$cd/tmp/certbot/public\u html
$printf“%s”>。众所周知的/acme挑战/
$sudo$(command-v python2 | | command-v python2.7 | | command-v python2.6)-c“导入BaseHTTPServer,SimpleHTTPServer;s=BaseHTTPServer.HTTPServer(“”,80),SimpleHTTPServer.SimpleHTTPRequestHandler);s.serve(forever()”
那我有
108.14.0.213---[09/Jul/2017 03:32:26]“GET/path?HTTP/1.1”404-
^CTraceback(最近一次通话最后一次):
文件“”,第1行,在
文件“/usr/lib/python2.7/SocketServer.py”,第236行,在serve\u中
轮询(U间隔)
文件“/usr/lib/python2.7/SocketServer.py”,第155行,在“重试”
返回函数(*args)
键盘中断

如果您只想在实例上安装SSl证书,那么最好生成一个CSR并与第三方提供商(如trustsign)签署一个。请注意,在这种情况下,您选择的SSL证书必须是通配符SSL证书类型,因为上面给出了您的名称格式。应该是
*ab.abc.com

如果这只是一个测试服务器,而您不关心安全警告,那么您可以按如下方式自行签名,但从浏览器访问url时必须接受安全警告

# openssl genrsa -out keyfile.key 2048
# openssl req -new -key keyfile.key -out certrequest.csr
# openssl x509 -req -days 3650 -in certrequest.csr -signkey keyfile.key -out certificate.pem
然后,您可以更新nginx配置,如下所示:

server {
    listen       80;
    listen       443;
    ssl on;
    ssl_certificate /path_to_your_public_Cert/certificate.pem;
    ssl_certificate_key /path_to_yourPrivate_key/keyfile.key;
    server_name ~^(aaa(?<site>[0-9]+)).ab.abc.com;
    location / {
        set $custom_port 90$site;
        if ($custom_port ~ "^.{3}$") {
            set $custom_port 900$site;
        }
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:$custom_port;
    }
}
服务器{
听80;
听443;
ssl-on;
ssl证书/路径到您的公共证书/certificate.pem;
ssl\u证书\u密钥/path\u到您的私钥/keyfile.key;
服务器名称(aaa(?[0-9]+).ab.abc.com;
地点/{
设置$custom_port 90$站点;
如果($custom_port~“^.{3}$”){
设置$custom_port 900$站点;
}
proxy_http_版本1.1;
代理设置头升级$http\U升级;
代理设置头连接“升级”;
代理设置头主机$Host;
代理通行证http://127.0.0.1:$海关港口;
}
}

提供您的nginx配置将是一个很好的起点,帮助您更新我的问题,包括nginx文件/etc/nginx/sites enabled/defaule我使用openssl和certbot生成SSL密钥有什么不同?我曾尝试使用certbot生成不接受通配符的通配符(*)域,并尝试为我的一个域生成一个密钥,该域不断出现404故障。一个区别是certbot将为您生成免费证书,但我始终与公认的第三方签署我的ssl证书。不能对certbot使用通配符(*)。您必须输入除逗号之外的所有域。如何在实例上安装SSL证书?我已经试过openssl了,但我现在并没有像你们说的那个样在浏览器上安全登录。我想那是因为我错过了机器上的SSL?那么,我如何使我的域安全呢?对于我上面提到的解决方案,如果您自己签名,您将得到安全警告,这是最后一个命令所做的。但是,对于此解决方案,如果您不想看到安全警告,则必须在创建
certrequest.csr
的步骤2停止。然后,您可以使用
csr
向第三方CA(如trustsign或commodo)签名并向您发送公钥。这将花费你几美元。如果你不想花钱,并且你熟悉CMD,那么你可以使用certbot。一步一步的指导如何做到这一点是在这里
server {
    listen       80;
    listen       443;
    ssl on;
    ssl_certificate /path_to_your_public_Cert/certificate.pem;
    ssl_certificate_key /path_to_yourPrivate_key/keyfile.key;
    server_name ~^(aaa(?<site>[0-9]+)).ab.abc.com;
    location / {
        set $custom_port 90$site;
        if ($custom_port ~ "^.{3}$") {
            set $custom_port 900$site;
        }
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:$custom_port;
    }
}