Nginx + Lua + Cookie gray-release control

 

Nginx + Lua + Cookie gray-release control

First, download and install

1, the installation OpenResty download page , openresty-1.15.8.2.tar.gz package (click to download ), package version list

2, installation instructions page (click to open)

3, reference CentOS

 

Second, the command to install

1、  - brew

- $ brew install openresty/brew/openresty

2, View openResty installation directory

- $ nginx -t

Figure:

 

3, set the alias

- $ export PATH=/usr/local/opt/openresty/nginx/sbin:$PATH

4, start

- $ nginx

Third, set the working directory, such as: configuration file conf such as: nginx.conf

1, by nginx -t

2, copy the profile folder to the working directory

- $ cp -r /usr/local/etc/nginx ~/work

修改nginx 文件夹为 conf

- $ mv nginx conf

如图:

 

四、 修改nginx.conf 引入Lua脚本

如图:

 

五、 设置resty.cookie

1、拷贝代码https://github.com/cloudflare/lua-resty-cookie/blob/master/lib/resty/cookie.lua

2、打开

查看安装目录,将cookie.lua 写入lualib/resty目录中

$ which nginx

$ open /usr/local/opt/openresty/lualib/resty

$ touch cookie.lua

$ vim cookie.lua { github code}

以下是Lua 脚本可用参考

如图:

 

 

代码文件:

https://docs.qq.com/doc/DZmJkaGpNd094RWpM

 

 

常用命令:

查看nginx 安装目录

which nginx

 

Alias

export PATH=/usr/local/opt/openresty/nginx/sbin:$PATH

 

查看配置文件

nginx -t

 

启动:

Nginx

 

nginx -p `pwd` -c ~/work/conf/nginx.conf

-p 指定当前工作目录

-c 指定配置文件目录

 

重载:

nginx -s reload

Guess you like

Origin www.cnblogs.com/zero0r1/p/11996840.html