I
I
Ivan2021-09-24 01:18:37
PHP
Ivan, 2021-09-24 01:18:37

How to fix wrong MIME or encoding for nginx?

I get a file with such content instead of css and js files, but this is provided that they are called via php, for example /adminer.php?file=default.css&version=4.7.6 if I call static /default.css then everything is OK
5OKbJIC.png

The problem arises when using the popular adminer.php script Response
headers
cache-control: immutable
content-encoding: gzip
content-type: text/css; charset=utf-8
date: Thu, 23 Sep 2021 22:14:19 GMT
expires: Fri, 23 Sep 2022 22:14:19 GMT
last-modified: Thu, 23 Sep 2021 22:14:19 GMT
server: nginx
strict -transport-security: max-age=31536000
vary: Accept-Encoding

Request headers:
:authority: site.example
:method: GET
:path: /adminer.php?file=default.css&version=4.7.6
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image /apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: ru-RU,ru;q=0.9,en-US ;q=0.8,en;q=0.7,zh-CN;q=0.6,zh;q=0.5
cache-control: max-age=0
cookie: adminer_settings.......
sec-ch-ua: " Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"
sec-ch-ua-mobile: ?0
sec-fetch-dest: document
sec -fetch-mode: navigate
sec-fetch-site: none
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2021-09-24
@karabanov

content-encoding: gzipThis is gzipped text. Apparently the script cannot unpack it. I will assume that this script is designed for this, but cannot do it, because the php-zip extension is not installed
Unpacked text:

curl -sH 'Accept-encoding: gzip' --output - https://site.example/adminer.php?file=default.css&version=4.7.6

Unpacked text:
curl -sH 'Accept-encoding: gzip' --output - "https://site.example/adminer.php?file=default.css&version=4.7.6" | gunzip -

Another thing may be the incorrect processing of the vary: Accept-Encoding
ngx_http_gzip_module header

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question