Forum: NGINX X-Accel-Redirect not passing Content-Type?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2ed442571c411e079086bf64a5909d7b?d=identicon&s=25 Kon Wilms (Guest)
on 2009-04-07 23:57
(Received via mailing list)
I'm having an odd problem with x-accel-redirect when using PHP to
process the request:

Setting the headers in the php script:
header("Content-Type: blah/blah");

Result page header still comes through as:
Content-Type: text/html

Hence I am seeing .html tacked on to attachment filename downloads in
Chrome and Safari.

Is x-accel ignoring the Content-Type?

Cheers
Kon
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2009-04-08 02:05
(Received via mailing list)
Hello!

On Tue, Apr 07, 2009 at 02:51:39PM -0700, Kon Wilms wrote:

> Chrome and Safari.
>
> Is x-accel ignoring the Content-Type?

No, it doesn't.  X-Accel-Redirect preserves Content-Type header
from original reply (the one which returned X-Accel-Redirect).

Check your php script actual reply to make sure it's actually
returns Content-Type header (actually as header, and no other
headers with same name).

Maxim Dounin
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 Michael Shadle (Guest)
on 2009-04-08 02:22
(Received via mailing list)
and if you want to FORCE the header

use

header('Content-Type: foo/bar', true);

the true will make sure it overrides
2ed442571c411e079086bf64a5909d7b?d=identicon&s=25 Kon Wilms (Guest)
on 2009-04-08 03:28
(Received via mailing list)
On Tue, Apr 7, 2009 at 5:14 PM, Michael Shadle <mike503@gmail.com>
wrote:
>>
>> No, it doesn't.  X-Accel-Redirect preserves Content-Type header
>> from original reply (the one which returned X-Accel-Redirect).
>>
>> Check your php script actual reply to make sure it's actually
>> returns Content-Type header (actually as header, and no other
>> headers with same name).

Thanks guys I will give it a shot :)

Cheers
Kon
2974d09ac2541e892966b762aad84943?d=identicon&s=25 michael (Guest)
on 2009-04-08 17:45
(Received via mailing list)
Are you setting Content-Type before X-Accel or after? I was just testing
X-Accel and ran into the same issue. Turns out I applied Content-Type
prior to X-Accel and it worked.

Per the documentation (or a mailing list post somewhere) X-Accel
*inherits* Content-Type, so I'd imagine if the server received an X-Accl
before Content-Type, the Content-Type would've been "determined"
already...

-Michael

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,897,899#msg-899
2ed442571c411e079086bf64a5909d7b?d=identicon&s=25 Kon Wilms (Guest)
on 2009-04-08 17:52
(Received via mailing list)
On Tue, Apr 7, 2009 at 3:34 PM, michael <nginx-forum@nginx.us> wrote:
> Are you setting Content-Type before X-Accel or after? I was just testing X-Accel and ran 
into the same issue. Turns out I applied Content-Type prior to X-Accel and it worked.

Before, but the result is the same (text/html).

> Per the documentation (or a mailing list post somewhere) X-Accel *inherits* 
Content-Type, so I'd imagine if the server received an X-Accl before Content-Type, the 
Content-Type would've been "determined" already...

Correct, and if anything is echoed to the browser it is also
immutable. I've checked for both of these.

Cheers
Kon
8a178ad712b49bd3d8031e00dfe1e3fd?d=identicon&s=25 Xia Qingran (Guest)
on 2009-04-15 11:20
(Received via mailing list)
On Wed, Apr 8, 2009 at 7:59 AM, Maxim Dounin <mdounin@mdounin.ru> wrote:
>
> No, it doesn't.  X-Accel-Redirect preserves Content-Type header
> from original reply (the one which returned X-Accel-Redirect).
>
> Check your php script actual reply to make sure it's actually
> returns Content-Type header (actually as header, and no other
> headers with same name).
>
> Maxim Dounin
>


Can nginx automaticly add Content-Type header when there is no
Content-Type in X-Accel-Redirect response?

If it could do, the backend CGI programs using X-Accel-Redirect will
feel better.


Regards,
--
$B2F@6A3(B
Xia Qingran
qingran.xia@gmail.com

Henny Youngman  - &quot;I told the doctor I broke my leg in two
places. He told me to quit going to those places.&quot; -
http://www.brainyquote.com/quotes/authors/h/henny_...
This topic is locked and can not be replied to.