Doesn't (or can't) NGINX's X-Accel-Redirect automatically pass the Content-Type header based on the file?
The NGINX part:
location /file {
rewrite /file/(.+) /file.php?params=$1 last;
}
location ~ /files {
internal;
root /path/to/files;
}
PHP:
$filename = '/files/test.png';
header('Content-Disposition: inline; filename = ' . $filename);
header('X-Accel-Redirect: ' . $filename);
I have to add header('Content-type: image/png');
to display the png directly, otherwise the server will return text/html
Isn't there a way to get the content type directly from NGINX? Or is this a bad idea (perhaps performance)? I could store the content type in the database with all the other stuff, that's not problem. Just wonder why it doesn't work.
Looks like this helps...
header('Content-type:');
but why?
Thanks!