我已经在亚马逊证书管理器中申请了证书。现在它具有“已发布”状态。 在EC2控制台中,我创建了Load Balancer。有2个听众:HTTP和HTTPS。我尝试了应用程序负载平衡器和经典负载平衡器,但无法通过HTTPS连接到我的站点。如何使用Elastic Load Balancer在Amazon EC2上设置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;
}
}
如何导入手动证书?或者有一种方法可以设置与Amazon证书的HTTPS连接? ( - sqlbot H/T @迈克尔)
您是否将证书设置为ELB? Doc在这里:http://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-add-or-delete-listeners.html – minamijoyo
@minamijoyo是的,我做到了。我需要配置后端实例身份验证(可选)吗? –
不,您不需要后端身份验证。在nginx访问或错误日志中是否有输出? – minamijoyo