Guest User

Untitled

a guest
Dec 18th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. <Error>
  2. <Code>AccessDenied</Code>
  3. <Message>
  4. AWS authentication requires a valid Date or x-amz-date header
  5. </Message>
  6. <RequestId></RequestId>
  7. <HostId></HostId>
  8. </Error>
  9.  
  10. server {
  11. listen 80;
  12. server_name my_elastic_ip;
  13.  
  14. location = /favicon.ico { access_log off; log_not_found off; }
  15.  
  16. location / {
  17. try_files $uri @s3;
  18. }
  19.  
  20. location @s3 {
  21. set $s3_bucket 'my_bucket.s3.amazonaws.com';
  22. set $url_full '$1';
  23. set $aws_access_key 'my_access_key';
  24. set $aws_secret_key 'my_secret_key';
  25.  
  26. proxy_http_version 1.1;
  27. proxy_set_header Host $s3_bucket;
  28. proxy_set_header x-amz-date $date_gmt;
  29. proxy_set_header Authorization 'AWS $aws_access_key:$aws_secret_key';
  30. proxy_hide_header x-amz-id-2;
  31. proxy_hide_header x-amz-request-id;
  32. proxy_hide_header Set-Cookie;
  33. proxy_ignore_headers "Set-Cookie";
  34. proxy_buffering off;
  35. proxy_intercept_errors on;
  36.  
  37. resolver 8.8.4.4 8.8.8.8 valid=300s;
  38. resolver_timeout 10s;
  39. proxy_pass http://$s3_bucket/$url_full;
  40. }
  41. }
  42.  
  43. set_by_lua $now "return ngx.cookie_time(ngx.time())";
  44. proxy_set_header x-amz-date $now;
  45.  
  46. sudo apt-get install nginx-extras
  47.  
  48. <Error>
  49. <Code>SignatureDoesNotMatch</Code>
  50. <Message>
  51. The request signature we calculated does not match the signature you provided. Check your key and signing method.
  52. </Message>
  53.  
  54. server {
  55. listen 80;
  56. server_name my_ip;
  57.  
  58. location = /favicon.ico { access_log off; log_not_found off; }
  59.  
  60. location / {
  61. try_files $uri @s3;
  62. }
  63.  
  64. location @s3 {
  65. set $s3_bucket 'my_bucket';
  66. set $key 'my_file';
  67. set $aws_access_key 'my_access_key';
  68. set $aws_secret_key 'my_secret_key';
  69.  
  70. set_by_lua $now "return ngx.cookie_time(ngx.time())";
  71. set $aws_signature '';
  72. set $string_to_sign "$request_methodnnnnx-amz-date:$nown/$s3_bucket/$key";
  73. set_hmac_sha1 $aws_signature $aws_secret_key $string_to_sign;
  74. set_encode_base64 $aws_signature $aws_signature;
  75.  
  76. proxy_http_version 1.1;
  77. proxy_set_header x-amz-date $now;
  78. proxy_set_header Authorization 'AWS $aws_access_key:$aws_signature';
  79. proxy_set_header Host $s3_bucket.s3.amazonaws.com;
  80. proxy_hide_header x-amz-id-2;
  81. proxy_hide_header x-amz-request-id;
  82. proxy_hide_header Set-Cookie;
  83. proxy_ignore_headers "Set-Cookie";
  84. proxy_buffering off;
  85. proxy_intercept_errors on;
  86.  
  87. resolver 8.8.4.4 8.8.8.8 valid=300s;
  88. resolver_timeout 10s;
  89. proxy_pass http://s3.amazonaws.com;
  90. }
  91.  
  92. <Code>AccessDenied</Code>
  93. <Message>Access Denied</Message>
Add Comment
Please, Sign In to add comment