Nginx set content type

Nginx will add Content-Type depend on suffix of url in response header. The suffix and Content-Type mapping are in /etc/nginx/mime.types. There are two ways to change Content-Type in Nginx.

1. edit mime.types to map suffix and Content-Type

Add a record in mime.types like following. All Content-Type of "*.video" url will be "video/mp4"

video/mp4                             video; 

2. add default_type in special location configuration

Add default_type to appoint default Content-Type for current url. All Content-Type of "/video" url will be "video/mp4"

location /video {
    root /video_file;
    index  index.html;
    default_type video/mp4;
}

EOF

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-14 06:20:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-14 06:20:02       100 阅读
  3. 在Django里面运行非项目文件

    2024-04-14 06:20:02       82 阅读
  4. Python语言-面向对象

    2024-04-14 06:20:02       91 阅读

热门阅读

  1. Debian安装和基本使用

    2024-04-14 06:20:02       42 阅读
  2. C#面:介绍 ArrayList 与 Array 的区别

    2024-04-14 06:20:02       35 阅读
  3. 委托 lambda linq之间的演变过程

    2024-04-14 06:20:02       33 阅读
  4. C#面:介绍 Hashtable 和 Dictionary的区别

    2024-04-14 06:20:02       36 阅读
  5. Android 14.0 USB鼠标右键改成返回键的功能实现

    2024-04-14 06:20:02       38 阅读
  6. 打不动的蓝桥杯

    2024-04-14 06:20:02       33 阅读
  7. 使用低空无人机图像对树种进行实例分割

    2024-04-14 06:20:02       35 阅读
  8. git 如何合并两个分支中的某些文件

    2024-04-14 06:20:02       38 阅读
  9. python 今日小知识1——parser

    2024-04-14 06:20:02       38 阅读
  10. tomcat按顺序启动应用

    2024-04-14 06:20:02       31 阅读
  11. xxl-job调度任务原理解析

    2024-04-14 06:20:02       32 阅读
  12. Qt | .pro开发经验笔记

    2024-04-14 06:20:02       37 阅读
  13. uniapp——长按识别二维码

    2024-04-14 06:20:02       38 阅读
  14. c#raft算法实现

    2024-04-14 06:20:02       33 阅读
  15. 蓝桥杯3527 阶乘的和 Python

    2024-04-14 06:20:02       38 阅读