Forum: NGINX Override proxy's incorrect Content-Type via mime settings

34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2011-09-23 18:38
(Received via mailing list)
Hi all -

I have an upstream proxy that sends the wrong Content-Type header for
a load of images. Sometime it doesn't send any header at all.

I'm trying to get Nginx not only to remove the upstream's Content-Type
header ("proxy_hide_header"), but also to insert the correct header.
Unfortunately, I can't hard-code the value as there are a variety of
image formats being used. "proxy_hide_header" doesn't seem to do
anything other than block the incorrect value, and
"proxy_ignore_headers" won't accept "Content-Type".

How can I both remote upstream's incorrect header, and also add the
header than Nginx *would* have used if it were serving the content
from local disk?
In other words, how do I add the header with a value derived from the
MIME settings currently configured, via the requested file's

Version 0.7.67, but can upgrade if required.

Many thanks,
Jonathan Matthews
London, UK
34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2011-09-23 18:46
(Received via mailing list)
On 23 September 2011 17:37, Jonathan Matthews <>
> How can I both remote upstream's incorrect header, and also add the
34011bc56457235a2caa5ed1d4a29f3c?d=identicon&s=25 Jonathan Matthews (Guest)
on 2011-09-28 00:24
(Received via mailing list)
Just a quick thread bump to see if anyone has any ideas ...
2974d09ac2541e892966b762aad84943?d=identicon&s=25 neoascetic (Guest)
on 2013-09-24 00:45
(Received via mailing list)
Have same problem, but for different types of files.

I have found a workaround using "map" directive, where pattern is an URI
extension and value is a mime-type, but seems a little bit weird and
requires to create a map from all possible extension. Is there any way
reuse standard "mime.types" together with Content-Type detection by URI

Posted at Nginx Forum:,215744,243078#msg-243078
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.