nginx学习(五) http模块
2015-12-06 15:46
901 查看
一、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后。看下面两个例子:
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为格式名称,可以在其他地方引用该格式。
作用域: http server
示例:
上例中gzip为name,‘’中的内容为format
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后。看下面两个例子:
root location ~ ^/awstats/ { root /home/awstats/; 访问:http://test.com/awstats/ 实际访问的是/home/awstats/awstats/ alias location ~ ^/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
相关文章推荐
- Http之Get/Post请求区别
- FFMPEG采集摄像头数据并切片为iPhone的HTTP Stream流
- Linux多线程网络编程(一)
- TCP 流协议和消息分帧的理解
- uva 563 - Crimewave 网络流
- HDU 3338 Kakuro Extension 网络流
- 网络电话语音通话的android实现
- HttpServletRequest常用获取URL相关的方法
- Linux网络流量控制工具—Netem(可用于网络故障注入)
- <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>标签再使用时报错
- 为何1M的网络下载速度只有120k/s
- 解决RecyclerView中使用UIL加载网络图片,在刷新时出现闪烁问题
- uva 10779 Collectors Problem 网络流
- iOS开发:iOS9.0适配之http修改为https、Bitcode、Scheme白名单等问题
- 一个极其简单的用golang net写的tcpip echoserver
- linux安装nginx并设置https(openssl)
- Android下setLatestEventInfo警告、Handler警告、SimpleDateFormat警告http://www.piaoyi.org/mobile-app/Android-se
- Java网络编程示例
- javaweb学习总结(七)——HttpServletResponse对象(一)
- 【linux】网络编程基础(c语言编程)