Use the following curl command:

curl -I url
curl -I curl -I https://www.rootadminz.com/media/new/category/old/nginx.gif

 

How to find out default mine types in Nginx

 

Look for config file named mime.types inside nginx config directory:

# find /etc/nginx -name mime.types

 

Use cat command or vi command to view mime.types file:

vi /etc/nginx/mime.types

 

Override content type with Nginx web server

Say when I request atom.xml file, there is

content-type: text/xml

 

And I want it to be the correct one as follows:

Content-Type: Content-type: text/html; charset=UTF-8

 

Again, I used curl command:

curl -I https://www.rootadminz.com/atom/atom.xml

 

To fix this update your mime.types file:

# vi /etc/nginx/mime.types

 

And make sure the following config exists:

application/atom+xml atom;

 

Save and close the file. Reload/restart the Nginx service. For example, GNU/Linux user can run:

# systemctl reload nginx

 

How to force Nginx to send specific Content-Type

 

Another option is to add the following directly to the config file:

types {
    application/atom+xml    atom xml;
} 

 

Nginx override content type for URL

 

It is also possible to override the content type for the given URL pattern. For example, I edited /etc/nginx/domains/rootadminz.com/default.conf and added the following in the server context:

    ### force utf-8 and content type, good bots for SEO ##
    location = /atom/atom.xml {
        ## override content-type ##
        types { } default_type "application/atom+xml; charset=utf-8";
 
        ## override header (more like send custom header using nginx) #
        add_header x-robots-tag "noindex, follow";
    } 

   

Save and close the file. Restart or reload nginx server:

# service nginx reload

 

Test it:

curl -I https://www.rootadminz.com/atom/atom.xml

 

Ця відповідь Вам допомогла? 0 Користувачі, які знайшли це корисним (0 Голосів)