我正在使用Rails 4,并将GET请求代理到另一个服务器,如下所示:
def proxy_video(path)
self.status = 200
response.headers["X-Accel-Redirect"] = "/proxy/#{path}"
render text: 'ok'
end
Run Code Online (Sandbox Code Playgroud)
在我的nginx配置中,我有这个:
location ~* ^/proxy/(.*?)/(.*) {
internal;
resolver 127.0.0.1;
# Compose download url
set $download_host $1;
set $download_url http://$download_host/$2;
# Set download request headers
proxy_set_header Host $download_host;
# Do not touch local disks when proxying content to clients
proxy_max_temp_file_size 0;
# Stream the file back send to the browser
proxy_pass $download_url?$args;
}
Run Code Online (Sandbox Code Playgroud)
对于代理GET请求,例如:
proxy_image('http://10.10.0.7:80/download?path=/20140407_120500_to_120559.mp4')
Run Code Online (Sandbox Code Playgroud)
但是,我想代理一个请求,该请求传递的文件列表不适合GET请求。因此,我需要将$ args中当前包含的内容作为POST数据传递。
我将如何代理此POST数据?-我需要做诸如response.method =:post之类的事情吗?-我该在哪里提供发布内容的参数?