{"id":1269,"date":"2012-09-06T18:38:01","date_gmt":"2012-09-06T09:38:01","guid":{"rendered":"http:\/\/blog.xcir.net\/?p=1269"},"modified":"2012-09-07T02:52:26","modified_gmt":"2012-09-06T17:52:26","slug":"generate-authorization-header-for-amazon-s3-in-varnish","status":"publish","type":"post","link":"https:\/\/blog.xcir.net\/?p=1269","title":{"rendered":"Generate authorization header for Amazon S3 in Varnish"},"content":{"rendered":"<p>Amazon S3 REST-API is necessary to generate signature.<br \/>\nvmod-awsrest generate to Authorization and Date header for Amazon S3.<\/p>\n<h3>How to use<\/h3>\n<h4>VCL<\/h4>\n<pre class=\"brush: plain; \">\n\r\nimport awsrest;\r\n\r\nbackend default {\r\n  .host = &quot;s3.amazonaws.com&quot;;\r\n  .port = &quot;80&quot;;\r\n}\r\n\r\nsub vcl_recv{\r\n  awsrest.s3_generic(\r\n  &quot;accessKey&quot;,            \/\/AWSAccessKeyId\r\n  &quot;secretKey&quot;,            \/\/SecretAccessKeyID\r\n  req.request,            \/\/HTTP-Verb\r\n  req.http.content-md5,   \/\/Content-MD5\r\n  req.http.content-type,  \/\/Content-Type\r\n  &quot;&quot;,                     \/\/canonicalizedAmzHeaders\r\n  req.url,                \/\/canonicalizedResource\r\n  now                     \/\/Date\r\n  );\r\n}\r\n\n<\/pre>\n<h4>Output<\/h4>\n<pre class=\"brush: plain; \">\n\r\n15 TxHeader     b Date: Tue, 03 Jul 2012 16:21:47 +0000\r\n15 TxHeader     b Authorization: AWS accessKey:XUfSbQDuOWL24PTR1qavWSr6vjM=\r\n\n<\/pre>\n<p>This module set to req.http.Authorization and req.http.Date, bereq is not use.<br \/>\nI recommend call in the vcl_recv.<br \/>\nAnd, be careful to default settings.<br \/>\nIf req.http.Authorization contains, it is not caching. (default setting)<\/p>\n<p>download here.<br \/>\n<a href=\"https:\/\/github.com\/xcir\/libvmod-awsrest\">libvmod-awsrest<\/a><\/p>\n<p>&#8212;<br \/>\nReference site<br \/>\n<a href=\"http:\/\/www.applelife100.com\/2012\/06\/23\/using-rest-api-of-amazon-s3-in-php-1\/\">PHP \u3067 Amazon S3 \u306e REST API \u3092\u4f7f\u7528 #1<\/a><br \/>\n<a href=\"http:\/\/s3.amazonaws.com\/doc\/s3-developer-guide\/RESTAuthentication.html\">Authenticating REST Requests<\/a><\/p>\n<p>\u65e5\u672c\u8a9e\u306f\u3053\u3063\u3061<br \/>\n<a href=\"http:\/\/blog.xcir.net\/index.php\/2012\/07\/varnish%E3%81%A7amazon-s3%E3%81%AE%E8%AA%8D%E8%A8%BC%E3%83%98%E3%83%83%E3%83%80%E3%82%92%E4%BD%9C%E3%82%8Bvmod%E3%82%92%E4%BD%9C%E3%81%A3%E3%81%A6%E3%81%BF%E3%81%9F\/\">Varnish\u3067Amazon S3\u306e\u8a8d\u8a3c\u30d8\u30c3\u30c0\u3092\u4f5c\u308bVMOD\u3092\u4f5c\u3063\u3066\u307f\u305f<br \/>\n<\/a><\/p>\n<div class='wp_social_bookmarking_light'>        <div class=\"wsbl_hatena\"><a href='\/\/b.hatena.ne.jp\/add?mode=confirm&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D1269&title=Generate%20authorization%20header%20for%20Amazon%20S3%20in%20Varnish' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/hatena.gif' alt='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' title='\u3053\u306e\u30a8\u30f3\u30c8\u30ea\u30fc\u3092\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af\u306b\u8ffd\u52a0' width='16' height='12' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_hatena_users\"><a href='\/\/b.hatena.ne.jp\/entry\/https:\/\/blog.xcir.net\/?p=1269' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Generate authorization header for Amazon S3 in Varnish' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='\/\/b.hatena.ne.jp\/entry\/image\/https:\/\/blog.xcir.net\/?p=1269' alt='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Generate authorization header for Amazon S3 in Varnish' title='\u306f\u3066\u306a\u30d6\u30c3\u30af\u30de\u30fc\u30af - Generate authorization header for Amazon S3 in Varnish'   class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_facebook\"><a href='http:\/\/www.facebook.com\/share.php?u=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D1269&t=Generate%20authorization%20header%20for%20Amazon%20S3%20in%20Varnish' title='Facebook \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/facebook.png' alt='Facebook \u306b\u30b7\u30a7\u30a2' title='Facebook \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_linkedin\"><a href='\/\/www.linkedin.com\/shareArticle?mini=true&url=https%3A%2F%2Fblog.xcir.net%2F%3Fp%3D1269&title=Generate%20authorization%20header%20for%20Amazon%20S3%20in%20Varnish' title='LinkedIn \u306b\u30b7\u30a7\u30a2' rel=nofollow class='wp_social_bookmarking_light_a' target=_blank><img src='https:\/\/blog.xcir.net\/wp-content\/plugins\/wp-social-bookmarking-light\/public\/images\/linkedin.png' alt='LinkedIn \u306b\u30b7\u30a7\u30a2' title='LinkedIn \u306b\u30b7\u30a7\u30a2' width='16' height='16' class='wp_social_bookmarking_light_img' \/><\/a><\/div>        <div class=\"wsbl_twitter\"><a href=\"https:\/\/twitter.com\/share\" class=\"twitter-share-button\" data-url=\"https:\/\/blog.xcir.net\/?p=1269\" data-text=\"Generate authorization header for Amazon S3 in Varnish\" data-lang=\"ja\">Tweet<\/a><\/div><\/div>\n<br class='wp_social_bookmarking_light_clear' \/>\n","protected":false},"excerpt":{"rendered":"<p>Amazon S3 REST-API is necessary to generate signature. vmod-awsrest generate to Authorization and Date header  <a href='https:\/\/blog.xcir.net\/?p=1269' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24,3],"tags":[5,33,34,44],"class_list":["post-1269","post","type-post","status-publish","format-standard","hentry","category-english","category-3","tag-varnish","tag-varnish3-0-2","tag-vmod","tag-vmod_awsrest","category-24-id","category-3-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"_links":{"self":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/1269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1269"}],"version-history":[{"count":9,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/1269\/revisions"}],"predecessor-version":[{"id":1279,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=\/wp\/v2\/posts\/1269\/revisions\/1279"}],"wp:attachment":[{"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xcir.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}