跳到主要内容

静态页镜像制作

cd /opt

git clone https://gitee.com/enation/docker.git -b 7.2.2_rc

Dockerfile所在目录:

/opt/docker/dockerfile/openresty

静态页使用redis+nginx+lua脚本的方式

reids配置

lua脚本存放在 redis-config 文件夹中。

在开始镜像制作之前,首先要确定好您的Redis类型,并在相应的lua脚本中配置您的redis信息

下面列出了lua脚本和redis类型的对应关系:

redis类型lua脚本
standalonePC静态页:single_connector_pc.lua
clusterPC静态页:cluster_connector_pc.lua

standalone方式:

--在这里配置您的Reids的ip和端口号
local ok, err = red:connect("redis ip", 6379) --如果不是默认端口号请相应修改
--请在这里配置您redis的密码
local res, err = red:auth("password")
-- 请在这里这里配置您PC端域名 静态页异常重定向地址
ngx.redirect("https://www.test.com/404.html")

cluster方式

--请在这里配置您Redis的集群节点信息   
serv_list = {
{ ip = "ip", port = port },
{ ip = "ip", port = port }
},
-- 请在这里这里配置您PC端域名 静态页异常重定向地址
ngx.redirect("https://www.test.com/404.html")

配置nginx

接下来需要修改nginx配置文件中相应脚本的名字

vi /opt/docker/dockerfile/openresty/nginx.conf

注意只需要修改脚本的名字,路径不要动:

   server {
listen 80;
server_name localhost;
location / {
default_type text/html;
#您只需要修改这行的lua名字即可,路径不要改
content_by_lua_file "/usr/local/openresty/nginx/lua/single_connector_pc.lua";
}
}

注意要把lua脚本的名字和您使用的对应上

制作镜像

cd /opt/docker/dockerfile/openresty/
docker build -t docker私服/openresty:版本号 .

推送镜像:

docker push docker私服/openresty:版本号