Multipurpose Internet Mail Extensions 多用途互联网邮件扩展

include mime.types;
default_type application/octet-stream;

| Syntax: | default_type mime-type;

| | —- | —- | | Default: | default_type text/plain; | | Context: | http, server, location |

文本类型

location /text {
default_type text/plain; # 指定为文本,不解析 html 标签
return 200 “

hi

/text”;
}
image.png

html

location /text {
default_type text/html; # 解析 html 标签
return 200 “

hi

/text”;
}
image.png

json

location /text {
default_type application/json;
return 200 ‘{“name”:”zhang3”,”age”:33}’;
}

image.png
注意是外单引号内双引号, 如果是外双引号内单引号
location /text {
default_type application/json;
return 200 “{‘name’:’zhang3’,’age’:33}”;
}
image.png