1、Nginx安装之后 default_type的值默认配置为application/octet-stream,而且目前已经配置很多域名,贸然的去修改这样的全局配置,可能应发不可用的问题 2、html结尾的文件,放到网站根目录下默认会被识别响应为text/html. 3、但是今天反馈的文件是没有后缀的,所以默认就成了application/octet-stream, 浏览器请求会直接进行...
default_type mime-type; 默认值是 text/plain ,但直接安装后都会给一个 application/octet-stream 。其实也就是在 types 中找不到类型,就会走这个默认值。我们可以来简单测试下。 代码语言:javascript 代码运行次数:0 运行 AI代码解释 location/mimetest/{alias/usr/local/nginx/html/;types{}default_type text/...
location ~ ^/get_text { default_type text/html; add_header Content-Type 'text/html; charset=utf-8'; return 200 '你好,世界!'; }
#将default_type application/octet-stream; 修改为default_typetext/html; 这样就默认表示一个文件是 html文件, 就可以在浏览器中查看。 #上面的方面可以解决文件不在浏览器中预览的情况,但是如果有文件的扩展名对应mime信息找不到,也会进行预览, 不管文件是不是文本文件,都是当成是文本文件。 default_type applica...
{include mime.types;#文件扩展名与文件类型映射表default_type application/octet-stream;#默认文件类型,默认为text/plain#access_log off; #取消服务日志log_format myFormat'$remote_addr–$remote_user [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_...
index index.html; } location /nginx_status { stub_status; allow 172.30.1.108; deny all; } location /main { index index.html; default_type text/html; echo "remote_addr = $remote_addr"; echo "***"; echo "args = $args"; echo ...
include /etc/nginx/mime.types; # 文件扩展名与类型映射表 default_type application/octet-stream; # 默认文件类型 include /etc/nginx/conf.d/*.conf; # 加载子配置项 # server段配置信息 server { listen 80; # 配置监听的端口 server_name localhost; # 配置的域名 # location段配置信息 location / {...
location /get_text { #这里也可以设置成 default_type text/plain; return 200 "This is nginx's text"; } location /get_json { default_type application/json; return 200 '{"name":"TOM","age":18}'; } 配置完毕后,重启nginx,浏览器分别访问上面两个路径,均能满足预期的效果 2、自定义服务日志 ...
default_type text/plain; return 200 'd6296a84657eb275c05c31b10924f6ea'; } 很多时候微信等程序都需要我们放一个txt的文件到项目里以验证项目归属,我们可以直接通过上边这种方式修改nginx即可,无需真正的把文件给放到服务器上 18、nginx配置upstream反向代理 http { ... upstream tomcats { server 192.168.106....
default_type application/octet-stream; #设定日志格式 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; ...