nginx学习(五) http模块
来源:互联网 发布:韩国人评论上瘾网络剧 编辑:程序博客网 时间:2024/05/29 19:46
一、http核心模块
1、alias
语法: alias file-path|directory-path;
默认值: no
作用域: location
该指令设置指定location使用的路径.注意它跟 root 相似,但是不改变文件的根路径,仅仅是使用文件系统路径
比如:
location /i/ {
alias /spool/w3/images/;
}
请求 "/i/top.gif" 将返回文件 "/spool/w3/images/top.gif".
在替换路径中可以使用变量.
alias 无法在正则的 location中使用. 如果你需要这么做,你必须结合使用指令rewrite 和 root.
2、root
追加路径
syntax: root path
default: root html
context: http, server, location, if in location
root specifies the document root for the requests. For example, with this configuration
location /i/ {
root /spool/w3;
}
A request for "/i/top.gif" will return the file "/spool/w3/i/top.gif". You can use variables in the argument.
root与alias区别:alias是将请求替换为alias的值。root是将请求追加到root后。看下面两个例子:
rootlocation ~ ^/awstats/ { root /home/awstats/;访问:http://test.com/awstats/ 实际访问的是/home/awstats/awstats/aliaslocation ~ ^/awstats/ { alias /home/访问:http://test.com/awstats/ 实际访问的是/home/
3、internal
只支持内部请求访问
error_page 404 /404.html;
location /404.html {
internal;
}
二、http log模块
1、access_log
语法: access_log path [format [buffer=size | off ] 默认值: access_log log/access.log combined
作用域: http, server, location
指令 access_log 指派路径、格式和缓存大小。
2、log_format
语法: log_format name format [format ...]
name为格式名称,可以在其他地方引用该格式。
log_format formatName 'format'access_log /user/access.log formatName默认值: log_format combined "..."
作用域: http server
示例:
log_format gzip '$remote_addr - $remote_user [$time_local] ': '"$request" $status $bytes_sent ': '"$http_referer" "$http_user_agent" "$gzip_ratio"';access_log /spool/logs/nginx-access.log gzip buffer=32k;
上例中gzip为name,‘’中的内容为format
- nginx学习(五) http模块
- nginx学习笔记五(nginx的事件模块定义)
- nginx学习笔记一(开发自己的http模块)
- Nginx学习笔记(五):怎样使用HTTP配置(上)
- Nginx学习笔记(八):HTTP过滤模块
- nginx 源码学习笔记(五)——nginx精粹-模块
- nginx 源码学习笔记(五)——nginx精粹-模块
- http学习(五)
- Nginx Http模块开发
- Nginx Http模块开发
- nginx---HTTP模块
- nginx HTTP模块组成
- nginx源码学习(五)
- python学习(五):模块
- nginx http模块 http过滤模块
- Nginx学习(7)—http过滤模块(1)
- Nginx学习(7)—http过滤模块(2)
- nginx学习笔记(2):开发一个简单的HTTP模块
- 找到数组中重复的和丢失的元素
- 二、文件与目录
- 调试的错误就是编程给你最好的东西,因为在每个错误上面都标志着前进的一步
- leetcode 287 Find the Duplicate Number
- 如果我来应聘产品经理岗位(二)
- nginx学习(五) http模块
- jquery瀑布流下拉加载(position定位版)
- 数组指针和指针数组
- 运行错误:error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or
- 关于git无法提交到远程库的问题
- 求出1--100之间的素数
- mysql5.7新特性
- c++ 算法设计与分析(第四版) 流水作业调度
- Linux进程管理