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条)

报告相同问题?

悬赏问题

  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题