我知道,S3可以提供一个简单的index.html文件,如果它在一个存储桶的根目录下,但是我的需要是提供很多简单的静态站点,S3每个账户有100个桶的限制,所以我必须使用nginx和一些子目录(如http://foo.bar.com/test/index.html ,桶总是foo.bar.com,我使用指向foo.bar.com的CNAME映射到域bar.com上.s3.amazonaws.com)。
这些静态网站应该可以从subdomain.bar.com访问,并直接提供index.html文件。
这是我的nginx conf:
server { listen 80; ## listen for ipv4 listen [::]:80 default ipv6only=on; ## listen for ipv6 server_name *.bar.com; set $subdomain ""; if ($host ~* "^(.+)\.bar\.com$") { set $subdomain $1; rewrite ^(.*)$ /$subdomain/index.html last; break; } location / { proxy_pass http://foo.bar.com/; } }
我几乎在那里:)现在发生什么是index.html文件被下载:我检查curl和内容types是八位字节/ strem。 我试图覆盖头文本/ HTML和成功,但我不断下载文件。
我相信我的错误是硬编码index.html,我给的索引指令是完全多余的,我不能使它工作。
我想要nginx做的是接收test.bar.com,并提供(不下载)位于http://foo.bar.com.s3.amazonaws.com/test/index.html
有人能帮我吗?
TIA
检查curl – 来自http://foo.bar.com/的回复是什么?
将文件放到S3时传递正确的Content-type: text/html 。
s3put -t text/html ....的窍门