douhui4699 2015-05-27 01:16
浏览 65
已采纳

AWS S3利用网站静态图像

We currently are moving our website to EC2 utilizing OpsWorks. Right now we reference all media files for the site with relative URL's in the coding... "/images/image1.jpg" and so on. Is there a way to alias the /images directory in our coding to utilize an S3 bucket? What we'd like to do is get big sized images out onto S3 so it's not stored withe each of our S3 instances.

I know we can create an alias DNS entry for the bucket itself, but then we'd have to reference that full URL inside of our coding. For instance, http://images.s3-website-us-east-1.amazonaws.com. We'd rather keep the URL referencing in the coding relative and an absolute path.

We are utilizing AWS Linux for the PHP/Apache front end EC2 instances.

  • 写回答

2条回答 默认 最新

  • douzi5214 2015-05-27 01:55
    关注

    If you're using Apache then you could proxy all the /images URL's using Apache's built-in proxy support. You would want to add something like this to your Apache configuration:

    ProxyRequests Off
    
    <Proxy *>
    Order deny,allow
    Allow from all
    </Proxy>
    
    ProxyPass /images/ http://images.s3-website-us-east-1.amazonaws.com/
    

    This actually creates a reverse proxy. When the Apache server sees a request that matches /images/ then it will reach out to the S3 URL to fetch the object and return it back to the client.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?