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

 

Related services

KVM VPS hosting

NVMe SSD and full root access, with Free Basic Managed Support.

Unmanaged dedicated servers

full root access and free IPMI KVM, with Free Basic Managed Support.

Managed dedicated servers

our engineers look after the server for you, from $135 a month.

Was this answer helpful?

Still stuck? Open a ticket