Nginx配置conf
来源:互联网 发布:python自动化开发基础 编辑:程序博客网 时间:2024/05/18 18:47
一、介绍
Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”, 是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服务器.
二、Location语法
语法:location [=|~|~*|^~] /uri/ { … }
注:
1、~ 为区分大小写匹配
2、~* 为不区分大小写匹配
3、!~和!~*分别为区分大小写不匹配及不区分大小写不匹配
示例一:
location / { }
匹配任何查询,因为所有请求都以 / 开头。但是正则表达式规则将被优先和查询匹配。
示例二:
location =/ {}
仅仅匹配/
示例三:
location ~* \.(gif|jpg|jpeg)$ {
rewrite \.(gif|jpg)$ /logo.png;
}
注:不区分大小写匹配任何以gif,jpg,jpeg结尾的文件
三、ReWrite语法
last - 基本上都用这个Flag。
break - 中止Rewirte,不在继续匹配
redirect - 返回临时重定向的HTTP状态302
permanent - 返回永久重定向的HTTP状态301
1、下面是可以用来判断的表达式:
-f和!-f用来判断是否存在文件
-d和!-d用来判断是否存在目录
-e和!-e用来判断是否存在文件或目录
-x和!-x用来判断文件是否可执行
2、下面是可以用作判断的全局变量
例:http://localhost:88/test1/test2/test.php
$host:localhost
$server_port:88
$request_uri:http://localhost:88/test1/test2/test.php
$document_uri:/test1/test2/test.php
$document_root:D:\nginx/html
$request_filename:D:\nginx/html/test1/test2/test.php
四、Redirect语法
server {
listen 80;
server_name start.igrow.cn;
index index.html index.php;
root html;
if ($http_host !~ "^star\.igrow\.cn$" [点击图片可在新窗口打开] {
rewrite ^(.*) http://star.igrow.cn$1 redirect;
}
}
五、防盗链location ~* \.(gif|jpg|swf)$ {
valid_referers none blocked start.igrow.cn sta.igrow.cn;
if ($invalid_referer) {
rewrite ^/ http://$host/logo.png;
}
}
六、根据文件类型设置过期时间
location ~* \.(js|css|jpg|jpeg|gif|png|swf)$ {
if (-f $request_filename) {
expires 1h;
break;
}
}
七、禁止访问某个目录
location ~* \.(txt|doc)${
root /data/www/wwwroot/linuxtone/test;
deny all;
}
- Nginx conf/nginx.conf配置
- Nginx-配置-nginx.conf
- nginx nginx.conf 配置
- nginx.conf配置说明
- nginx.conf配置详解
- Nginx配置conf
- Nginx.conf 配置小结
- nginx.conf 配置详解
- nginx配置www.conf
- nginx.conf配置说明
- nginx.conf配置
- nginx.conf配置参考
- nginx.conf的配置
- nginx中conf配置
- nginx.conf配置详解
- nginx conf location 配置
- nginx.conf配置
- nginx.conf配置
- 新建Maven项目,出现问题
- 计算机软件保护条例2013年修订
- 面向报文UDP和面向字节流TCP的区别
- ags js api学习之dojo初步
- 一、MyBatis简介与配置MyBatis+Spring+MySql
- Nginx配置conf
- C++连接SQL Server数据库
- Mac下好用的HTTP/HTTPS抓包工具Charles
- shiro入门实例
- 【Eclipse提高开发速度-插件篇】google V8,用于调试Nodejs
- python 2.7 数据连接
- 重写equals方法时为什么需要重写hashCode方法
- Python实现股票行情接收V013
- 如何提高VS2010的性能,VS2010不再卡