Skip to content

Commit 1e25374

Browse files
committed
update README Format
1 parent 4d28495 commit 1e25374

File tree

1 file changed

+48
-49
lines changed

1 file changed

+48
-49
lines changed

README.md

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@
159159
#### <a name="Nginx_Web4_knowledge"/> 第四章 高级配置
160160
+ 基本语法:location [=|~|~*|^~] /uri/ { … }
161161
1. `= `:严格匹配。如果这个查询匹配,那么将停止搜索并立即处理此请求。
162-
1. `~ `:为区分大小写匹配(可用正则表达式)
163-
1. `!~ `:为区分大小写不匹配
164-
1. `!~*`:为不区分大小写不匹配
165-
1. ` ^~ `:如果把这个前缀用于一个常规字符串,那么告诉nginx 如果路径匹配那么不测试正则表达式
162+
2. `~ `:为区分大小写匹配(可用正则表达式)
163+
3. `!~ `:为区分大小写不匹配
164+
4. `!~*`:为不区分大小写不匹配
165+
5. ` ^~ `:如果把这个前缀用于一个常规字符串,那么告诉nginx 如果路径匹配那么不测试正则表达式
166166
+ [Perl 正则表达式参考](http://www.runoob.com/perl/perl-regular-expressions.html)
167167
+ 正则中需要转义的特殊字符小结
168168
- [1] ` $` 匹配输入字符串的结尾位置。如果设置了 RegExp 对象的 Multiline 属性,则 $ 也匹配 ‘\n' 或 ‘\r'。要匹配 $ 字符本身,请使用 \$。
@@ -182,10 +182,10 @@
182182
- [2] `location ~ /documents/Abc { }`:匹配任何以 /documents/ 开头的地址,匹配符合以后,还要继续往下搜索
183183
- [3] **目录匹配:**
184184
1. 可以匹配静态文件目录`(static/lib)`
185-
1. HLS直播目录`(/home/HLS/stream123/index.m3u8)`
186-
1. HLS/MP4/FLV点播视频目录`(/home/HLS/stream123.m3u8)`
187-
1. 匹配URL地址:`http://127.0.0.1/live/stream123/index.m3u8`
188-
1. nginx.conf 配置信息
185+
2. HLS直播目录`(/home/HLS/stream123/index.m3u8)`
186+
3. HLS/MP4/FLV点播视频目录`(/home/HLS/stream123.m3u8)`
187+
4. 匹配URL地址:`http://127.0.0.1/live/stream123/index.m3u8`
188+
5. nginx.conf 配置信息
189189
```
190190
# 匹配任何以/live/ 开头的任何查询并且停止搜索。任何正则表达式将不会被测试
191191
location ^~ /live/ {
@@ -195,10 +195,10 @@
195195
```
196196
+ 后缀匹配
197197
1. 匹配任何后缀文件名`gif|jpg|jpeg|png|css|js|ico|m3u8|ts` 结尾的请求
198-
1. TS 文件匹配`http://127.0.0.1/live/stream123/11.ts`
199-
1. M3U8 文件匹配`http://127.0.0.1/live/stream123/index.m3u8`
200-
1. 匹配URL地址:`http://127.0.0.1/hls/123.m3u8`
201-
1. nginx.conf 配置信息
198+
2. TS 文件匹配`http://127.0.0.1/live/stream123/11.ts`
199+
3. M3U8 文件匹配`http://127.0.0.1/live/stream123/index.m3u8`
200+
4. 匹配URL地址:`http://127.0.0.1/hls/123.m3u8`
201+
5. nginx.conf 配置信息
202202
```
203203
location ~* \.(gif|jpg|jpeg|png|css|js|ico|m3u8|ts)$ {
204204
root /home/tinywan/HLS/;
@@ -304,7 +304,7 @@
304304
+ [默认配置信息](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/default-config.md)
305305
+ 开发入门
306306
+ Nginx与Lua的整体目录关系
307-
```Lua
307+
```Bash
308308
.
309309
├── conf
310310
│ ├── nginx.conf -- Nginx 配置文件
@@ -369,25 +369,25 @@
369369
+ nginx.conf 配置信息
370370
```Lua
371371
http {
372-
lua_package_path "/opt/openresty/nginx/lua/lua-resty-redis/lib/?.lua;;";
373-
server {
374-
listen 80;
375-
server_name localhost;
376-
location ~ \/.+\/.+\.(m3u8|ts) {
377-
if ($uri ~ \/([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)(|-).*\.(m3u8|ts)) {
378-
set $app_name $1;
379-
set $a $2;
380-
}
381-
set $stream_id "";
382-
default_type 'text/html';
383-
rewrite_by_lua_file /opt/openresty/nginx/lua/proxy_pass_cdn.lua;
384-
proxy_connect_timeout 10;
385-
proxy_send_timeout 30;
386-
proxy_read_timeout 30;
387-
proxy_pass $stream_id;
372+
lua_package_path "/opt/openresty/nginx/lua/lua-resty-redis/lib/?.lua;;";
373+
server {
374+
listen 80;
375+
server_name localhost;
376+
location ~ \/.+\/.+\.(m3u8|ts) {
377+
if ($uri ~ \/([a-zA-Z0-9]+)\/([a-zA-Z0-9]+)(|-).*\.(m3u8|ts)) {
378+
set $app_name $1;
379+
set $a $2;
388380
}
389-
381+
set $stream_id "";
382+
default_type 'text/html';
383+
rewrite_by_lua_file /opt/openresty/nginx/lua/proxy_pass_cdn.lua;
384+
proxy_connect_timeout 10;
385+
proxy_send_timeout 30;
386+
proxy_read_timeout 30;
387+
proxy_pass $stream_id;
390388
}
389+
390+
}
391391
}
392392
```
393393
+ [Lua脚本proxy_pass_cdn.lua](https://github.com/Tinywan/Lua-Nginx-Redis/blob/master/Openresty/lua-resty-redis/proxy_pass_cdn.lua)
@@ -466,16 +466,15 @@
466466
+ nginx.conf
467467
```Lua
468468
location /cjson {
469-
content_by_lua_block {
470-
local cjson = require "cjson"
471-
472-
local json = cjson.encode({
473-
foo = "bar",
474-
some_object = {},
475-
some_array = cjson.empty_array
476-
})
477-
ngx.say(json)
478-
}
469+
content_by_lua_block {
470+
local cjson = require "cjson"
471+
local json = cjson.encode({
472+
foo = "bar",
473+
some_object = {},
474+
some_array = cjson.empty_array
475+
})
476+
ngx.say(json)
477+
}
479478
}
480479
```
481480
+ curl 请求
@@ -508,15 +507,15 @@
508507
+ 基本用法
509508
```Lua
510509
location /start {
511-
content_by_lua_block {
512-
local session = require "resty.session".start()
513-
session.data.name = "OpenResty Fan Tinywan"
514-
session:save()
515-
ngx.say("<html><body>Session started. ",
516-
"<a href=/test>Check if it is working</a>!</body></html>")
517-
ngx.say(session.data.name,"Anonymous")
518-
}
519-
}
510+
content_by_lua_block {
511+
local session = require "resty.session".start()
512+
session.data.name = "OpenResty Fan Tinywan"
513+
session:save()
514+
ngx.say("<html><body>Session started. ",
515+
"<a href=/test>Check if it is working</a>!</body></html>")
516+
ngx.say(session.data.name,"Anonymous")
517+
}
518+
}
520519
```
521520
+ curl 请求
522521
```Bash

0 commit comments

Comments
 (0)