Nginx add header instructions

Source: Internet
Author: User


The nginx configuration file uses the add_header command to set the response header. The response header is generally in the form of key: value, for example, "Content-Encoding: gzip, Cache-Control: no-store ", the command is:

Add_header Cache-Control no-store
Add_header Content-Encoding gzip

However, there is a very common characteristic of response header comparison, that is, Content-Type. You can specify charset when setting the Type, for example, "text/html; charset = utf-8 ", because the Semicolon exists, and the semicolon is used as the end character in the configuration file, you need to use quotation marks for configuration. The configuration is as follows:

Add_header Content-Type: 'Text/html; charset = utf-8 ';

In addition, because the charset key is not set separately, you need to use Content-Type to specify the charset to set the response charset.


Add custom header

Nginx. conf, as follows:

Location /{
Add_header X-UA-Compatible 'ie = Edge, chrome = 1'; # Here is the custom header root www/htdocs; index. php index.html index.htm;
}

X-UA-Compatible is the name, IE = Edge, and chrome = 1 is the value, which can be customized at will. You can add an http request to the html

The code is as follows: Copy code

<Meta http-equiv = "X-UA-Compatible" content = "IE = Edge, chrome = 1">

Restart nginx and the browser after adding the custom head, and then open the page to view the effect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.