# X-Accel-Redirect and Content-Type

**URL:** <https://www.ruby-forum.com/t/x-accel-redirect-and-content-type/198653>\
**Category:** NGINX\
**Created:** [November 4, 2010, 9:38pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-and-content-type/198653 "2010-11-04T21:38:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 4, 2010, 9:38pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-and-content-type/198653/1 "2010-11-04T21:38:45Z")

</div>

Currently the application that is passing the X-Accel-Redirect uri back  
to nginx must set the Content-type header otherwise it will  
automatically be set to the default\_type setting. Is there a way to get  
nginx to automatically detect the mime settings and transmit it? I’ve  
tried: fastcgi\_ignore\_headers Content-Type, but that gave me the error  
(taken from  
[nginx, x-accel-redirect and mime types - Server Fault](http://serverfault.com/questions/195060/nginx-x-accel-redirect-and-mime-types)):

[warn] 3988#1288: invalid value “Content-Type”

Note: I’m using the latest windows build to test on.

Posted at Nginx Forum:

> **[X-Accel-Redirect and Content-Type](https://forum.nginx.org/read.php?2,147744,147744#msg-147744)**
>
> Currently the application that is passing the X-Accel-Redirect uri back to nginx must set the Content-type header otherwise it will automatically be set to the default\_type setting. Is there a way to get nginx to automatically detect the mime...

---

<div class="post-metadata">

**Author:** ![soulodd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@soulodd](https://www.ruby-forum.com/u/soulodd)\
**Post date:** [November 5, 2010, 12:21am UTC](https://www.ruby-forum.com/t/x-accel-redirect-and-content-type/198653/2 "2010-11-05T00:21:59Z")

</div>

Hello!

On Thu, Nov 04, 2010 at 04:37:50PM -0400, soulodd wrote:

> Currently the application that is passing the X-Accel-Redirect uri back  
> to nginx must set the Content-type header otherwise it will  
> automatically be set to the default\_type setting.

This is not true.

If not explicitly set by script together with X-Accel-Redirect -  
Content-Type will be set by nginx according to extension of  
redirect destination (and types/default\_type defined, see [1]).

[1] [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/HttpCoreModule#types)

> Is there a way to get  
> nginx to automatically detect the mime settings and transmit it?

See above for extension-based detection - this is how it works by  
default. Just not returning Content-Type with X-Accel-Redirect is  
enough.

If you are talking about content sniffing - no, it’s not available  
(at all).

> I’ve  
> tried: fastcgi\_ignore\_headers Content-Type, but that gave me the error  
> (taken from  
> [http://serverfault.com/questions/195060/nginx-x-accel-redirect-and-mime-types](http://serverfault.com/questions/195060/nginx-x-accel-redirect-and-mime-types)):
> 
> [warn] 3988#1288: invalid value “Content-Type”

Directive fastcgi\_ignore\_headers never accepted “Content-Type”  
value.

Maxim D.

---

<div class="post-metadata">

**Author:** ![soulodd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@soulodd](https://www.ruby-forum.com/u/soulodd)\
**Post date:** [November 5, 2010, 4:33pm UTC](https://www.ruby-forum.com/t/x-accel-redirect-and-content-type/198653/3 "2010-11-05T16:33:34Z")

</div>

Thank you for your reply. You are correct – text/html was being sent  
prior to the response. I should have seen that. Much appreciated.

Posted at Nginx Forum:

> **[Re: X-Accel-Redirect and Content-Type](https://forum.nginx.org/read.php?2,147744,148006#msg-148006)**
>
> Currently the application that is passing the X-Accel-Redirect uri back to nginx must set the Content-type header otherwise it will automatically be set to the default\_type setting. Is there a way to get nginx to automatically detect the mime...
