没有定义解析s3-eu-west-1.amazonaws.com的解析器

时间:2018-04-05 16:53:22

标签: nginx amazon-s3

我的所有xml文件都存储在AWS S3中,我想通过我的网站显示它们:

Nginx conf:

location ~ \.xml$ {

    proxy_pass https://s3-eu-west-1.amazonaws.com/bucket-name/sitemap$request_uri;

}

但我得到了502并且日志说

[error] 13295#13295: *26 no resolver defined to resolve s3-eu-west-1.amazonaws.com

如果我定义一个像

这样的解析器
resolver s3-eu-west-1.amazonaws.com;

我得到了

[error] 14430#14430: *7 s3-eu-west-1.amazonaws.com could not be resolved (110: Operation timed out),

感谢您的帮助

3 个答案:

答案 0 :(得分:2)

我找到了解决方案:

location ~ \.xml$ {

    rewrite ^ /<bucket>/sitemap$request_uri break;
    proxy_pass https://s3-eu-west-1.amazonaws.com;
}

答案 1 :(得分:2)

您的VPC中的AWS DNS为likely at 10.0.0.2(它是基本CIDR加2)。

添加resolverresolver_timeout

location ~ \.xml$ {
    resolver         10.0.0.2 valid=300s;
    resolver_timeout 10s;

    proxy_pass https://s3-eu-west-1.amazonaws.com/bucketname/sitemap$request_uri;
}

注意:在EC2 Classic中AWS DNS server is located at 172.16.0.23

答案 2 :(得分:0)

此实例中的解析程序将是您用于解析DNS名称的本地或外部DNS服务器,而不是s3网址。