[PATCH] Upstream: support named location for X-Accel-Redirect

Toshikuni Fukaya toshikuni-fukaya at cybozu.co.jp
Mon Nov 10 00:54:13 UTC 2014


(2014/11/08 0:59), Igor Sysoev wrote:
> On 04 Nov 2014, at 14:18, Toshikuni Fukaya <toshikuni-fukaya at cybozu.co.jp> wrote:
>> Upstream: support named location for X-Accel-Redirect.
> Could please you provide usage examples?

Here is my (simplified) config:

server {
  location / {
   proxy_pass http://app;

  location @contents {
   proxy_pass http://contents/$upstream_http_x_contents_url;

app is a upstream application server, it processes all client requests.
contents is a some of blob server (like as S3) to supply images, css and 
so on.

When clients access to nginx, app will check a some of ACL to such 
requests, then reply with x-accel-redirect and x-contents-url headers.
Finally, nginx will return a content from contents upstream.
In this time, x-accel-redirect will be set to @contents and 
x-contents-url will be an appropriate content url.

The key of this strategy is that all requests is passed to app and can 
be checked by it.
If location @contents is a normal location such as /contents, a client 
request to /contents will not be passed app. It is not comfortable for me.

Toshikuni Fukaya

More information about the nginx-devel mailing list