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.