# X-Accel-Redirect

**URL:** <https://www.ruby-forum.com/t/x-accel-redirect/184915>\
**Category:** NGINX\
**Created:** [March 10, 2010, 11:46am UTC](https://www.ruby-forum.com/t/x-accel-redirect/184915 "2010-03-10T11:46:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![alberto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@alberto](https://www.ruby-forum.com/u/alberto)\
**Post date:** [March 10, 2010, 11:46am UTC](https://www.ruby-forum.com/t/x-accel-redirect/184915/1 "2010-03-10T11:46:22Z")

</div>

I’m using nginx in two different points.

As reverse proxy, and as webserver.

1. Webserver with php fastcgi

[http://www.domain.com/file.zip](http://www.domain.com/file.zip), is really a php that stores some stats  
about our customers downloads.  
When it has stored all the info it sends an X-Accel-Direct. It works  
perfectly.

1. Reverse proxy

We have setup some nginx in our customers nodes, to they get better  
latency, speed, etc…

Everything works ok.

Now the prob is that for earch download, nginx-2 ( reverse proxy ) has  
to download everythin from nginx-2 ( webserver ) and then upload  
everything to the client.

This generates a lot of traffic.

As we only need to get some info about the client, we have thought about  
storing the download folder into nginx-2, and be able to send the  
x-accel-redirect from nginx-1 to nginx-2.

So the php gets executed in the nginx-1, info stored, and the phisical  
download done from nginx-2, without transfering gigs and gigs of data.

Is there an easy way to rename the X-Accel-Redirect header on nginx-2 so  
we can sent it from nginx-1 to nginx-2? So nginx-1 works with the  
standard X-Accel-Redirect header, and nginx-2 with ( example )  
X-Local-Redirect.

Or another way to accomplish this workflow?

Thnx a lot!

Posted at Nginx Forum:

> **[X-Accel-Redirect](https://forum.nginx.org/read.php?2,62208,62208#msg-62208)**
>
> I'm using nginx in two different points. As reverse proxy, and as webserver. 1) Webserver with php fastcgi http://www.domain.com/file.zip, is really a php that stores some stats about our customers downloads. When it has stored all the info it send

---

<div class="post-metadata">

**Author:** ![alberto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@alberto](https://www.ruby-forum.com/u/alberto)\
**Post date:** [March 10, 2010, 12:47pm UTC](https://www.ruby-forum.com/t/x-accel-redirect/184915/2 "2010-03-10T12:47:15Z")

</div>

Hello!

On Wed, Mar 10, 2010 at 05:45:34AM -0500, Alberto wrote:

[…]

> As we only need to get some info about the client, we have  
> thought about storing the download folder into nginx-2, and be  
> able to send the x-accel-redirect from nginx-1 to nginx-2.

fastcgi\_ignore\_header X-Accel-Redirect;  
fastcgi\_pass\_header X-Accel-Redirect;

See here for details (in Russian, wiki has no translation yet -  
feel free to add one; Google Translate is your friend):

> **[Модуль ngx\_http\_fastcgi\_module](http://nginx.org/ru/docs/http/ngx_http_fastcgi_module.html)**

> **[Модуль ngx\_http\_fastcgi\_module](http://nginx.org/ru/docs/http/ngx_http_fastcgi_module.html)**

Maxim D.

---

<div class="post-metadata">

**Author:** ![alberto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@alberto](https://www.ruby-forum.com/u/alberto)\
**Post date:** [March 10, 2010, 1:00pm UTC](https://www.ruby-forum.com/t/x-accel-redirect/184915/3 "2010-03-10T13:00:08Z")

</div>

Thnx, this one should work!!!

In the doc is not clear, but I suppose i have to add both.

fastcgi\_ignore\_headers, just to not process the header, and  
fastcgi\_pass\_header to sent it to the next node.

Or does fastcgi\_pass\_header already ignores it?

Posted at Nginx Forum:

> **[Re: X-Accel-Redirect](https://forum.nginx.org/read.php?2,62208,62217#msg-62217)**
>
> I'm using nginx in two different points. As reverse proxy, and as webserver. 1) Webserver with php fastcgi http://www.domain.com/file.zip, is really a php that stores some stats about our customers downloads. When it has stored all the info it send

---

<div class="post-metadata">

**Author:** ![alberto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@alberto](https://www.ruby-forum.com/u/alberto)\
**Post date:** [March 10, 2010, 2:17pm UTC](https://www.ruby-forum.com/t/x-accel-redirect/184915/4 "2010-03-10T14:17:59Z")

</div>

Thnx a lot for it worked flawlessly 🙂

We have reduced our traffic from 280 mbit / sec to 140 mbit on some  
servers 😃

Posted at Nginx Forum:

> **[Re: X-Accel-Redirect](https://forum.nginx.org/read.php?2,62208,62240#msg-62240)**
>
> I'm using nginx in two different points. As reverse proxy, and as webserver. 1) Webserver with php fastcgi http://www.domain.com/file.zip, is really a php that stores some stats about our customers downloads. When it has stored all the info it send

---

<div class="post-metadata">

**Author:** ![alberto](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ea5d25/32.png) [@alberto](https://www.ruby-forum.com/u/alberto)\
**Post date:** [March 10, 2010, 1:11pm UTC](https://www.ruby-forum.com/t/x-accel-redirect/184915/5 "2010-03-10T13:11:50Z")

</div>

Hello!

On Wed, Mar 10, 2010 at 06:59:27AM -0500, Alberto wrote:

> Thnx, this one should work!!!
> 
> In the doc is not clear, but I suppose i have to add both.
> 
> fastcgi\_ignore\_headers, just to not process the header, and  
> fastcgi\_pass\_header to sent it to the next node.

Yes. I wrote exact snippet you have to add to appropriate  
location with fastcgi\_pass.

> Or does fastcgi\_pass\_header already ignores it?

No.

Maxim D.
