2023-08-11 16:41:21 +08:00
2023-06-22 18:12:44 +08:00
2023-08-11 16:41:21 +08:00
2022-01-15 18:40:22 +08:00
2023-07-23 21:45:34 +08:00
.
2023-05-29 15:51:55 +08:00
2023-05-06 23:14:55 +08:00
fix
2023-01-08 00:04:37 +08:00
2023-05-29 15:50:24 +08:00

使用自动化脚本进行配置文件和lua代码的更新。

以macos本地环境为例,使用cp_scripts_local_macos.sh:

➤ ./cp_scripts_local_macos.sh                                                                                                                                                                                                                                                                                   20:31:54
+ mkdir -p /usr/local/etc/openresty/conf.d
+ cp conf/local_macos/admin.conf conf/local_macos/music-room.conf conf/local_macos/ts.conf /usr/local/etc/openresty/conf.d/
+ cp scripts/*.lua /usr/local/opt/openresty/resty_funcs/

第一次更新记得在nginx.conf里面include配置目录conf.d:

➤ tail -n 5 /usr/local/etc/openresty/nginx.conf
    #}

    include /usr/local/etc/openresty/conf.d/*.conf;

}

检查配置没有问题:

➤ openresty -t
nginx: the configuration file /usr/local/etc/openresty/nginx.conf syntax is ok
nginx: [warn] 1024 worker_connections exceed open file resource limit: 256
nginx: configuration file /usr/local/etc/openresty/nginx.conf test is successful

resty里请求域名地址时无法使用本地的/etc/hosts文件,需在nginx.conf文件中的http模块内添加resolver配置显式指定:

http {
    ...
    resolver 8.8.8.8;
    ...
}

测试服所使用的DNS服务:

➤ ssh weli@moicen.com
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Wed Dec 29 20:10:34 2021 from 111.193.10.152
[weli@moicen ~]$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 183.60.82.98
nameserver 183.60.83.19
[weli@moicen ~]$

使用上述nameserver的时候,请求upyun会提示no route to host错误,使用8.8.8.8偶尔也会出现

put upload.lua into:

/usr/local/opt/openresty/nginx/resty_funcs

post file:

$ curl --location --request POST 'localhost/upload' \
--form '=@"/Users/weli/works/task_server/src/test/resources/file_example_JPG_100kB.jpeg"'

nginx config

/usr/local/etc/openresty/nginx.conf
location /upload {
   content_by_lua_file /usr/local/opt/openresty/nginx/resty_funcs/upload.lua;
}

enable log:

error_log  /usr/local/etc/openresty/logs/error.log;

MacOS

Binary:

➤ which openresty                                                                                                              20:17:35
/usr/local/bin/openresty

Configuration:

pwd                                                                                                                          20:17:57
/usr/local/opt/openresty
pwd                                                                                                                          20:20:00
/usr/local/opt/openresty/nginx/resty_funcs

Update:

weli@ovpn-12-178:/u/l/o/o/n/resty_funcs
➤ pwd                                                                                                                          20:20:38
/usr/local/opt/openresty/nginx/resty_funcs
weli@ovpn-12-178:/u/l/o/o/n/resty_funcs
➤ cp ~/works/resty_functions/* .                                                                                               20:20:40
weli@ovpn-12-178:/u/l/o/o/n/resty_funcs
➤

Pre-Install lua third module

luarocks install lua-resty-jit-uuid 
luarocks install lua-resty-jwt
S
Description
OpenResty configs and Lua scripts
Readme 469 KiB
Languages
Lua 76.4%
Shell 23.6%