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 ...
随机推荐
- java运行jar包时候加载指定目录的其他jar支持包
最近发生一个小故障,调试好的项目,发布成jar包后无法找到oracle的驱动,研究了一下解决了.记录一下. 写了一个run.sh脚本 #!/bin/bash cd ~ cd app nohup jav ...
- CSS 样式属性
大小 width 宽 body { min-width:1200px; height 高 } ...
- pdf.js 使用汇总
https://www.cnblogs.com/iPing9/p/7154753.htmlhttp://blog.csdn.net/m0_38021128/article/details/708684 ...
- Expression<Func<T>>和Func<T>
以前用EF的时候,由于where的时候有Expression<Func<T>>和Func<T>两种查询条件,误用了Func<T>那个重载,后来还想通过f ...
- Java static和final
java提高篇(七)-----关键字static static 在Java中并不存在全局变量的概念,但是我们可以通过static来实现一个“伪全局”的概念,在Java中static表示“全局”或者“静 ...
- Django Rest Framework 请求流程
用户请求到django,首先经过wsgi,中间件,然后到url路由系统,执行视图类中继承APIView执行as_view方法,在源码中可以看到VPIView继承了django的View类,通过supe ...
- python内置函数每日一学 -- any()
any(iterable) 官方文档解释: Return True if any element of the iterable is true. If the iterable is empty, ...
- socket 模拟 HTTP请求
一.socket介绍 网络由下往上分为物理层.数据链路层.网络层.传输层.会话层.表示层和应用层.IP协议对应于网络层,TCP协议对应于传输层,而HTTP协议对应于应用层.socket则是对TCP/I ...
- element-ui Message组件源码分析整理笔记(八)
Message组件源码: main.js import Vue from 'vue'; import Main from './main.vue'; import { PopupManager } f ...
- 绝对良心提供百度网盘的jdk1.8源码下载包含sun包的
但是openjdk网站有提供的: http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/6bfaecb8ff77/src/share/classes/ 或者直 ...