这个问题类似于this one,但是在aws s3资源上执行x-accel-redirect.前者试图将上游头设置为本地请求.这很好.但是现在我已将内容移至亚马逊s3,并且我想对s3对象实施相同的受限下载.这是我的nginx配置proxy_pass_heade...
这个问题类似于this one,但是在aws s3资源上执行x-accel-redirect.前者试图将上游头设置为本地请求.这很好.但是现在我已将内容移至亚马逊s3,并且我想对s3对象实施相同的受限下载.
这是我的nginx配置
proxy_pass_header X-Accel-Redirect;
passenger_pass_header X-Accel-Redirect;
location ~* ^/download_zip/(.*) {
internal;
resolver 8.8.8.8 valid=300s;
proxy_buffering off;
proxy_set_header Content-Length "";
proxy_set_header Cookie "";
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-uid;
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-meta-mode;
proxy_hide_header x-amz-meta-mtime;
proxy_hide_header x-amz-meta-gid;
proxy_hide_header x-amz-version-id;
proxy_hide_header accept-ranges;
# Do not touch local disks when proxying
# content to clients
proxy_method GET;
proxy_pass_request_body off;
proxy_max_temp_file_size 0;
proxy_pass_header Content-MD5;
add_header Content-MD5 $upstream_http_content_md5;
# proxy_set_header Content-MD5 "123123123123123";
proxy_pass https://a_b_c_assets.s3-east.amazonaws.com/$1$is_args$args;
}
导轨部分是
headers['X-Accel-Redirect'] = '/download_zip/uploads/' + params[:story_id] +'/' + params[:story_id] + '.zip?' + secure_part
headers['X-Accel-Expires'] = 'max'
headers['Content-MD5'] = checksum
除了未将Content-MD5传递到代理请求之外,其他所有操作都正常.
任何帮助都非常感谢.
另一个similar question在这里
解决方法:
proxy_pass_header X-Accel-Redirect;
passenger_pass_header X-Accel-Redirect;
# this is intermediate location that stores header
# to variable and rewrites to another location
location ^~ /download_zip/ {
internal;
set $Content_MD5 $upstream_http_content_md5;
rewrite ^/(.+) /amazon_$1;
}
location ^~ /amazon_download_zip/ {
internal;
resolver 8.8.8.8 valid=300s;
proxy_buffering off;
proxy_set_header Content-Length "";
proxy_set_header Cookie "";
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-uid;
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-meta-mode;
proxy_hide_header x-amz-meta-mtime;
proxy_hide_header x-amz-meta-gid;
proxy_hide_header x-amz-version-id;
proxy_hide_header accept-ranges;
# Do not touch local disks when proxying
# content to clients
proxy_method GET;
proxy_pass_request_body off;
proxy_max_temp_file_size 0;
proxy_pass_header Content-MD5;
add_header Content-MD5 $Content_MD5;
proxy_pass https://a_b_c_assets.s3-east.amazonaws.com/;
}
沃梦达教程
本文标题为:ruby-on-rails-Nginx将上游头传递给远程请求
基础教程推荐
猜你喜欢
- ruby-on-rails-使用Nginx的Rails的多阶段环境 2023-09-21
- R语言数可视化Split violin plot小提琴图绘制方法 2022-12-10
- R语言基于Keras的MLP神经网络及环境搭建 2022-12-10
- R包ggtreeExtra绘制进化树 2022-12-14
- swift版webview加载网页进度条效果 2023-07-05
- asm基础——汇编指令之in/out指令 2023-07-06
- R语言-如何将科学计数法表示的数字转化为文本 2022-11-23
- UEFI开发基础HII代码示例 2023-07-07
- swift 字符串String的使用方法 2023-07-05
- Go web部署报错panic: listen tcp xxxxxxx:8090: bind: cannot assign requested address 2023-09-05