nginx之location.md
安装echo模块
下载模块
# pwd
/root
# git clone https://github.com/openresty/echo-nginx-module
重新编译
先查看版本,然后根据需要看是否需要升级nginx版本,这里是按原先的版本来添加echo模块。
# /opt/nginx/sbin/nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_mp4_module --with-http_spdy_module --with-http_flv_module --with-http_stub_status_module --with-pcre
# wget http://nginx.org/download/nginx-1.6.3.tar.gz
# tar -xf nginx-1.6.3.tar.gz
# cd nginx-1.6.3
# ./configure --prefix=/opt/nginx --with-http_ssl_module --with-http_mp4_module --with-http_spdy_module --with-http_flv_module --with-http_stub_status_module --with-pcre --add-module=/root/echo-nginx-module/
# make
注意不要进行install 操作,为了避免覆盖正在使用的nginx程序。
# mv /opt/nginx/sbin/nginx /opt/nginx/sbin/nginx.old
# cp objs/nginx /opt/nginx/sbin/
# cd /opt/nginx/sbin/
# ./nginx -V
nginx version: nginx/1.6.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_mp4_module --with-http_spdy_module --with-http_flv_module --with-http_stub_status_module --with-pcre --add-module=/root/echo-nginx-module/
# kill -USR2 `cat /opt/nginx/logs/nginx.pid`
# kill -QUIT `cat /opt/nginx/logs/nginx.pid.oldbin`
location 配置
nginx 配置文件
server {
server_name www.example.com;
listen 80;
access_log /data/log/nginx/www.example.com.log;
root /opt/web/www.example.com;
location / {
echo "/";
}
location = /{
echo "=/";
}
location = /nginx {
echo "=/nginx";
}
location /nginx/ {
echo "/nginx/";
}
location ~ \.(gif|jpg|png|js|css)$ {
echo "small-gif/jpg/png";
}
location ~* \.png$ {
echo "all-png";
}
location ^~ /static/ {
echo "static";
}
}
下面需要做好本地hosts的域名解析,这里不做演示。
测试如下
# tree /opt/web/www.example.com/
/opt/web/www.example.com/
└── index.html
0 directories, 1 file
# curl http://www.example.com
=/
# curl http://www.example.com/nginx
=/nginx
# curl http://www.example.com/nginx/index.html
/nginx
# curl http://www.example.com/yyf/pangtouyu.png
small-gif/jpg/png
# curl http://www.example.com/yyf/pangtouyu.PNG
all-png
# curl http://www.example.com/static/pangtouyu.png
static
# curl http://www.example.com/static/pangtouyu.PNG
static
# curl http://www.example.com/nginx/a.txt
/
nginx之location.md的更多相关文章
- rewrite规则写法及nginx配置location总结
rewrite只能放在server{},location{},if{}中,并且只能对域名后边的除去传递的参数外的字符串起作用. 例如http://seanlook.com/a/we/index.php ...
- Nginx之location 匹配规则详解
有些童鞋的误区 1. location 的匹配顺序是“先匹配正则,再匹配普通”. 矫正: location 的匹配顺序其实是“先匹配普通,再匹配正则”.我这么说,大家一定会反驳我,因为按“先匹配普通, ...
- nginx 中location和root
nginx 中location和root,你确定真的明白他们关系? 2016-01-17 14:48 3774人阅读 评论(1) 收藏 举报 分类: linux(17) 版权声明:本文为博主原创文 ...
- Nginx 的 Location 配置指令块
最近一段时间在学习 Nginx ,以前一直对 Nginx 的 Location 配置很头大,最近终于弄出点眉目.总结如下:nginx 配置文件,自下到上分为三种层次分明的结构: | http b ...
- 快速掌握Nginx(二) —— Nginx的Location和Rewrite
1 location详解 1.location匹配规则 Nginx中location的作用是根据Url来决定怎么处理用户请求(转发请求给其他服务器处理或者查找本地文件进行处理).location支持正 ...
- nginx之location的匹配规则
nginx之location的匹配规则 一.语法规则 location [=|~|~*|^~] /uri/ { - } 符号 含义 = 开头表示精确匹配 ^~ 开头表示 uri 以某个常规字符串开头 ...
- Nginx的location匹配规则
一 Nginx的location语法 location [=|~|~*|^~] /uri/ { … } = 严格匹配.如果请求匹配这个location,那么将停止搜索并立即处理此请求 ...
- nginx:location指令中的正则表达式
nginx:location指令中的正则表达式 uri匹配步骤 官网说明https://docs.nginx.com/nginx/admin-guide/web-server/web-server/ ...
- Nginx的location配置规则梳理
Nginx几乎是当下绝大多数公司在用的web应用服务,熟悉Nginx的配置,对于我们日常的运维工作是至关重要的,下面就Nginx的location配置进行梳理: 1)location匹配的是nginx ...
随机推荐
- 获取CheckBox的Text值
有在网上看到一个问题,就是尝试去获取Checkbox的值.技术难度并不高,不过有时间,还是做做练习.创建一个网页: 写click事件,在CheckBox被选取时,才去获取CheckBox的Text的值 ...
- windows下使用python操作redis(Visual Studio Code)
1.编辑工具: Visual Studio Code(windows环境) 2.redis服务器:这里用了远程连接,需要配置redis.conf. (1)注释 #bind 127.0.0.1 (2)设 ...
- oracle中scott/tiger、sys、SYSDBA、system都是什么用
scott 是个演示用户,是让你学习ORACLE用的 SYSDBA 不是用户,可以认为是个权限,超级权限详细点说吧 超级用户分两种 SYSDBA和SYSOPTSYSOPT 后面3 ...
- [android] fragment的动态创建
在一个商业软件中,会有很多的界面,如果没一个界面对应一个activity,那么activity会非常的多,清单文件也会非常的乱,谷歌在android3.0以后引入了新的概念叫fragment frag ...
- ssh免密登陆及时间设置
1.ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa // 在自己主机生成私钥和公钥 2.scp id_rsa.pub centos@s201:/home/centos ...
- Code Signal_练习题_digitDegree
Let's define digit degree of some positive integer as the number of times we need to replace this nu ...
- css-文字和图片在容器内垂直居中的简单方法
方法一.使用line-heigh使多行文字居中或图片居中 把文字包裹在一个inline-block元素中vertical-align middle,外部元素line-heigh等于高度 <div ...
- SQLServer 远程链接MySql数据库详解
SQLServer 远程链接MySql数据库详解 by:授客 QQ:1033553122 测试环境: Microsoft Windows XP Professional 版本2000 Service ...
- TestLink笔记(一):环境配置+安装
注:转载请加上原文链接,谢谢! 本文的安装环境是Windows操作系统. (一) 前期准备 1.XAMPP下载(下载5.6的版本) https://www.apachefriends.org/ ...
- Azure 托管镜像和非托管镜像对比
目前中国区 Azure 也已经可以使用命令制作托管镜像了.但对于托管镜像和非托管镜像,就像托管磁盘和非托管磁盘一样,很多人可能一开始无法理解.这里就此进行了一个简单对比: 通过对比测试,这里总结了这两 ...