curl - Proxying PUT HTTP requests to AWS S3 fails -
i working on creating proxy relay http requests amazon s3. proxy uses nginx right ngx_aws_auth module adds necessary headers http requests client not need to.
nginx configuration:
http { include mime.types; default_type application/octet-stream; sendfile on; client_body_in_file_only clean; client_body_buffer_size 32k; client_max_body_size 300m; send_timeout 300s; keepalive_timeout 65; gzip on; server { listen 8000; location / { proxy_pass https://test-bucket.s3.amazonaws.com; aws_access_key xxxxx; aws_secret_key yyyyyy; s3_bucket test-bucket; proxy_set_header authorization $s3_auth_token; proxy_set_header x-amz-date $aws_date; } } }
almost except when trying upload larger file.
get:
$ curl -vx http://192.168.99.131:8000/a.txt ; echo * connect() 192.168.99.131 port 8000 (#0) * trying 192.168.99.131... * connected 192.168.99.131 (192.168.99.131) port 8000 (#0) > /a.txt http/1.1 > user-agent: curl/7.29.0 > host: 192.168.99.131:8000 > accept: */* > < http/1.1 200 ok < server: nginx/1.6.3 < date: sun, 30 aug 2015 18:18:50 gmt < content-type: application/x-www-form-urlencoded < content-length: 1 < connection: keep-alive < x-amz-id-2: 1f/eqtkju= < x-amz-request-id: a970d9bcf5d5890b < last-modified: sat, 29 aug 2015 00:58:33 gmt < etag: "0cc175b9c0f1b6a831c399e269772661" < accept-ranges: bytes < * connection #0 host 192.168.99.131 left intact
put small file:
$ echo 'a'>a;curl -vx put -d @a http://192.168.99.131:8000/a.txt * connect() 192.168.99.131 port 8000 (#0) * trying 192.168.99.131... * connected 192.168.99.131 (192.168.99.131) port 8000 (#0) > put /a.txt http/1.1 > user-agent: curl/7.29.0 > host: 192.168.99.131:8000 > accept: */* > content-length: 1 > content-type: application/x-www-form-urlencoded > * upload sent off: 1 out of 1 bytes < http/1.1 200 ok < server: nginx/1.6.3 < date: sun, 30 aug 2015 18:20:03 gmt < content-length: 0 < connection: keep-alive < x-amz-id-2: gf/hvpsr+r2r/j7qquf0= < x-amz-request-id: f499d02f2d28b6eb < etag: "0cc175b9c0f1b6a831c399e269772661" < * connection #0 host 192.168.99.131 left intact
put larger file without adjusting header:
curl -vvvx put -d @1408133479717.jpg http://192.168.99.131:8000/a.jpg * connect() 192.168.99.131 port 8000 (#0) * trying 192.168.99.131... * connected 192.168.99.131 (192.168.99.131) port 8000 (#0) > put /a.jpg http/1.1 > user-agent: curl/7.29.0 > host: 192.168.99.131:8000 > accept: */* > content-length: 320356 > content-type: application/x-www-form-urlencoded > expect: 100-continue > < http/1.1 100 continue < http/1.1 200 ok < server: nginx/1.6.3 < date: sun, 30 aug 2015 18:33:45 gmt < content-length: 0 < connection: keep-alive < x-amz-id-2: im+nmggfzccp+/mfldwdr/zwjfs= < x-amz-request-id: 3b86e54874009d73 < etag: "8d04fbe9d623bf03bb828594ca272063" < * connection #0 host 192.168.99.131 left intact
this uploads partial file size of 320356 bytes, original file 825210 bytes.
put larger file , adjusting header:
[vagrant@gripper nginx]$ curl -vvvx put -h "content-length: 825210" -d @1408133479717.jpg http://192.168.99.131:8000/a.jpg * connect() 192.168.99.131 port 8000 (#0) * trying 192.168.99.131... * connected 192.168.99.131 (192.168.99.131) port 8000 (#0) > put /a.jpg http/1.1 > user-agent: curl/7.29.0 > host: 192.168.99.131:8000 > accept: */* > content-length: 825210 > content-type: application/x-www-form-urlencoded > expect: 100-continue > < http/1.1 100 continue * empty reply server * connection #0 host 192.168.99.131 left intact curl: (52) empty reply server
my question is:
how can upload file correct size using curl?
Comments
Post a Comment