【发布时间】:2017-12-13 01:09:32
【问题描述】:
谁能向我解释一下如何在我的 AWS EC2 上安装 SSL。我读了很多文章,这些步骤很简单,但我尝试了其中的几个,但没有一个有效。
我有一个 AWS EC2
EC2 静态 IP,54.X.X.X
子域,xxxx.ab.abc.com
安全组:端口来自
定制 80、443、9000-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
server {
listen 80;
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;
}
}
无论我点击哪个子域,我如何将 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
【问题讨论】:
-
提供您的 nginx 配置将是帮助您开始的好地方
-
谢谢,更新我的问题以包含 nginx 文件 /etc/nginx/sites-enabled/defaule
标签: amazon-web-services ssl amazon-ec2 ssl-certificate