Amazon S3的静态网站 - 重定向到HTTPS的HTTP

问题描述:

我即将推出采用S3 /的Cloudfront一个静态的网站。我不需要HTTPS的网站,但该网站的当前迭代是通过HTTPS提供,并有数百个链接和索引是HTTPS网址。

I'm about to launch a static website using S3/Cloudfront. I don't need HTTPS for the site, but the current iteration of the website is served over HTTPS and has hundreds of links and indexed URLs that are HTTPS.

我一直在寻找了几个小时,不能找到一种方法时,只使用S3 /的Cloudfront重定向我们的HTTPS URL以HTTP。目前,HTTPS URL将拒绝连接,而不是重定向到页面的HTTP版本。

I've been searching for hours and can't find a way to redirect our HTTPS URLs to HTTP when only using S3/Cloudfront. Currently the HTTPS URL will refuse the connection instead of redirecting to the HTTP version of the page.

由于没有阿帕奇现在看来,这是不可能做到这一点。任何提示?

With no Apache it seems it is not possible to do this. Any hints?

静态网站托管在S3上不支持HTTPS,除非您使用全域路径,即 example.com.s3-网站美-east-1.amazonaws.com 。既然你想保持你的网址,你将不得不使用一个CloudFront的分布处理SSL。

Static website hosting on S3 does not support HTTPS unless you use the full domain path, i.e. example.com.s3-website-us-east-1.amazonaws.com. Since you want to keep your URL, you'll have to use a CloudFront distribution to handle SSL.

  1. 上传您的SSL证书CloudFront的: AWS IAM上传服务器证书--server证书名称CertificateName --certificate体文件:// public_key_certificate_file --private-key文件://privatekey.pem --certificate链文件: // certificate_chain_file --path / CloudFront的/路径/ [1]
  2. 创建一个CloudFront的分布和配置为这样:
    • 原产地域名:您的S3存储
    • 备用域名(的CNAME):希望为您的网站的位置,例如: example.com或www.example.com
    • SSL证书:选择在步骤1中上载的SSL证书
    • 自定义SSL客户端支持:除非你需要真的老客户的兼容性,选择仅支持服务器名称指示客户端,节省$ 600个
  1. Upload your SSL certificate to CloudFront: aws iam upload-server-certificate --server-certificate-name CertificateName --certificate-body file://public_key_certificate_file --private-key file://privatekey.pem --certificate-chain file://certificate_chain_file --path /cloudfront/path/ [1]
  2. Create a cloudfront distribution and configure as so:
    • Origin Domain Name: your s3 bucket
    • Alternate Domain Names (CNAMEs): desired location for your website, e.g. example.com or www.example.com
    • SSL Certificate: Select the SSL certificate you uploaded in step 1.
    • Custom SSL Client Support: Unless you need compatibility for really old clients, select "Only Clients that support Server Name Indication" and save $600.

[1]如果你有麻烦添加您的证书CloudFront的看看这篇文章了解更多信息:http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/SecureConnections.html#cnames-and-https-procedure

[1] if you have trouble adding your certificate to CloudFront check out this article for further information: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/SecureConnections.html#cnames-and-https-procedure