【发布时间】:2013-09-18 08:00:01
【问题描述】:
我正在为我的 nginx 配置文件 defualt.conf 配置重写规则以接受请求并将它们路由到 S3 存储桶。
现在我正在为 URL 的后半部分获取正确的内容,但我无法连接或添加我的 S3 存储桶的 url。
这是我的代码:
location / {
# This code rewrites the original request, and adds the host without www in front
# E.g. if someone requests
# /directory/file.ext?param=value
# from the coolsite.com site the request is rewritten to
# /coolsite.com/directory/file.ext?param=value
rewrite ^(.*)$ /$host_without_www$1 break;
# The rewritten request is passed to S3
proxy_pass http://sites.nginx.com;
}
在上面的重写中,我想在/$host_without_www 之前添加site.nginx.com,这是我的存储桶名称,我尝试使用.(dot) 和unix 样式{$variable_to_concat},但没有用。
有人可以建议我正确的方法吗?
感谢您的关注
【问题讨论】:
-
这个站点的服务器名称是什么?请求
/directory/file.ext?param=value时是否要获取内容site.nginx.com/coolsite.com/directory/file.ext?param=value -
这是存储在s3中的静态站点结构
sites.nginx.com(bucket name)/coolsite.com(folder name)/index.html(files) -
我搞定了。实际上,我尝试连接的 url 有语法错误。我必须为日志启用调试模式,然后检查值。这解决了问题!谢谢
-
我再发一个简单的配置,你可以试试。
标签: php amazon-web-services nginx amazon-s3