OpenResty
yml
services:
openresty:
image: openresty/openresty:1.21.4.3-alpine
container_name: openresty
ports:
- "8080:80"
volumes:
- ./resty-conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf
- ./conf.d:/etc/nginx/conf.d
- ./lua:/usr/local/openresty/nginx/lua
restart: unless-stopped需要 mkdir conf/nginx.conf 和 lua 目录
暴露端口 8080
lua_package_path 中的 ?.lua 表示在 lua 目录中查找 lua 文件,;; 必不可少,否者会覆盖默认路径。
nginx
worker_processes 1;
events {
worker_connections 1024;
}
http {
lua_package_path "/usr/local/openresty/lua/?.lua;;";
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
}nginx
lua
ngx.header["Content-Type"] = "application/json"
ngx.say("ngx.var.uri = ", ngx.var.uri)
ngx.say('{"msg": "Hello OpenResty"}')版本说明
OpenResty: A.B.C.D
│ │ │ └─ OpenResty patch
│ │ └── OpenResty minor
│ └──── Nginx minor
└────── Nginx major