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

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料