Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 使用AmazonS3配置Nginx,并使用请求url的位置从S3获取html_Amazon Web Services_Nginx_Amazon S3 - Fatal编程技术网

Amazon web services 使用AmazonS3配置Nginx,并使用请求url的位置从S3获取html

Amazon web services 使用AmazonS3配置Nginx,并使用请求url的位置从S3获取html,amazon-web-services,nginx,amazon-s3,Amazon Web Services,Nginx,Amazon S3,Nginx中有没有一种好方法可以配置Nginx从S3 bucket获取html内容 我想从s3存储桶中获取静态html内容。我试图通过代理传递来实现这一点 请求的url结构是/file/path1/path2/。 默认的conf文件是: location /file/path1/path2/ { proxy_pass http://s3.amazonaws.com/example-bucket/file/path1/path2/index.html; } 还有,如何从请求的url获取路

Nginx中有没有一种好方法可以配置Nginx从S3 bucket获取html内容

我想从s3存储桶中获取静态html内容。我试图通过代理传递来实现这一点

请求的url结构是/file/path1/path2/。 默认的conf文件是:

location /file/path1/path2/ {
    proxy_pass http://s3.amazonaws.com/example-bucket/file/path1/path2/index.html;
}
还有,如何从请求的url获取路径1和路径2。 我看过文档,还没有找到一个简单的方法


我希望能得到详细的解释。

这是我为可能遇到这个问题的人(可能是新手)所做的

location ~* ^/some_bucket/(.*)/(.*)/.* {
    proxy_pass http://s3.amazonaws.com/some_bucket/$1/$2/$1_$2.html;
}
~*表示不区分大小写的正则表达式匹配^

例如,用户输入www.example.com/some_bucket/folder1/folder2/text

然后,它被处理为

~*确保不区分大小写的搜索(对于区分大小写的skip*(表示仅放置~))

^匹配www.example.com

/一些桶/是匹配的

*表示任何字符的任何数字(对于任何数字,替换为[0-9]*)

()确保捕获匹配的值

因此,1美元能抓住folder1

$2捕获文件夹2

然后

*不带括号匹配任何字符,但不捕获匹配的值

现在,可以使用捕获的值在amazon bucket中查找文件

proxy_pass$1/$2/$1_$2.html

位置块选择算法可能很有用

只是重复: