【发布时间】:2017-06-29 15:48:03
【问题描述】:
我已在 Amazon Certificate Manager 中申请证书。现在它的状态为“已发布”。 在 EC2 控制台中,我创建了负载均衡器。有 2 个侦听器:HTTP 和 HTTPS。我尝试了 Application Load Balancer 和 Classic Load Balancer,但无法通过 HTTPS 连接到我的站点。
我的 nginx 配置:
server {
listen 80;
#listen 443 ssl;
rewrite ^(.*) https://$host$1 permanent;
server_name site.com www.site.com;
root /home/ubuntu/www/site.com/wordpress;
index index.php;
client_max_body_size 20m;
gzip on;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
location ~* ^/(\.htaccess|xmlrpc\.php)$ {
return 404;
}
location ~ /\. {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
set $is_https 'off';
if ($http_x_forwarded_proto ~ 'https') {
set $is_https 'on';
}
proxy_set_header HTTPS $is_https;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
#try_files $uri $uri/ /index.php?$args; # permalinks
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
如何手动导入证书?或者有办法用亚马逊证书建立 HTTPS 连接?
【问题讨论】:
-
您是否将证书设置为 ELB?文档在这里:docs.aws.amazon.com/elasticloadbalancing/latest/classic/…
-
@minamijoyo 是的,我做到了。是否需要配置后端实例认证(可选)?
-
不,您不需要后端身份验证。 nginx访问或错误日志中有输出吗?
-
你是打负载均衡器还是直接打服务器?
-
@MarkB 你是什么意思?
标签: amazon-web-services ssl nginx amazon-ec2 ssl-certificate