Maxim Dounin
July 16, 2021 12:02PM
Hello!

On Fri, Jul 16, 2021 at 08:38:39AM +0200, Marcel Kočíšek wrote:

> Stack overflow:
>
> https://stackoverflow.com/questions/68362629/nginx-is-sending-for-json-file-text-html-conent-type
>
> I have problem with my nginx server in version nginx:1.19-alpine running on
> Docker.
>
> Static files with .json extension are served with mime type text/html.
> Request:
>
> curl 'example.json' -H 'Accept: application/json' -H 'Accept-Language:
> en-US,en;q=0.5' --compressed -H 'Referer: http://192.168.16.201/' -H
> 'X-Requested-With: XMLHttpRequest'
>
> Response:
>
> HTTP/1.1 200 OKServer: nginxDate: Tue, 13 Jul 2021 12:23:51
> GMTContent-Type: text/html;charset=utf-8Content-Length:
> 14746Connection: keep-aliveContent-Encoding: gzipCache-Control:
> no-storeAccept-Ranges: bytesVary: OriginVary:
> Access-Control-Request-MethodVary:
> Access-Control-Request-HeadersLast-Modified: Thu, 01 Jan 1970 00:00:01
> GMT
>
> mime.types are configured correctly.

Two possible answers I can think of:

1. The MIME types aren't configured correctly. Check your nginx
configuration, notably if the "mime.types" is actually included in
the configuration and not overwritten at different levels with
something like "types {}" (see http://nginx.org/r/types). Just in
case, the "nginx -T" output might be helpful to see actual nginx
configuration.

2. The response is returned by a backend server rather than nginx.
Various "Vary" headers as well as no space before "charset=" in
the "Content-Type" suggest this might be the case.

Hope this helps.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Fwd: NGINX is sending for .json file text/html Conent type

Marcel Kočíšek July 16, 2021 02:40AM

Re: Fwd: NGINX is sending for .json file text/html Conent type

Maxim Dounin July 16, 2021 12:02PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 249
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready