我之前用了nginx proxy,我是这样做的,在nginx中配置一个location
location ~ /.*\.(jpg|png|txt) {
proxy_pass http://10.x.x.x;
}
再在subrequest中请求内部服务器的资源(10.x.x.x是我内部的某个服务器),这没有问题。
我现在想实现的是对于任意一个url,比如我想去拉一张某图片网站上的图片,那我的proxy_pass 的backend server我就不知道怎么配了。
好的
下次我直接发邮件列表
------------------ Original ------------------
Sender: "agentzh"<age...@gmail.com>;
Send time: Thursday, Feb 21, 2013 4:41 AM
To: "Collin/hug"<413...@qq.com>;
Cc: "openresty"<openresty@googlegroups.com>;
Subject: Re: Reply: nginx subrequest写cache的问题
Hello!
2013/2/20 Collin/hug:
> 春哥,
>
> 请教另外一个问题,我想通过ngx_http_subrequest这个函数去下载文件,
> ngx_int_t ngx_http_subrequest(ngx_http_request_t *r,
> ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr,
> ngx_http_post_subrequest_t *ps, ngx_uint_t flags)
> 但这个函数的uri要求是nginx conf中配置的location,我如何实现去下载任何一个url呢?
>
你需要同时配合使用标准的 ngx_proxy 模块。子请求机制工作在 C 层面上,而不是 HTTP 协议层面上,尽管其用户界面看起来有点儿像 HTTP :)
同时抄送给 openresty 中文邮件列表:http://openresty.org/#Community
建议加入此列表并在那里讨论这样的问题,谢谢合作 :)
Best regards,
-agentzh