nginx add_header instruction usage method

  • 2020-05-07 20:54:10
  • OfStack

response header1 is generally in the form of key: value, such as "Content-Encoding: gzip, Cache-Control: no-store", with the following command:


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

However, there is a common response header comparison feature of 10 points, Content-Type, which can specify charset when it sets the type, for example: "text/html; charset= utf-8 ", because there is a semicolon, and the semicolon is used as the ending character in the configuration file, so it needs to be enclosed in quotation marks when configuration. The configuration is as follows:


add_header  Content-Type 'text/html; charset=utf-8';

In addition, since key of charset is not set separately, charset of charset needs to be specified by Content-Type to set charset of the response.


Related articles: