Files
resty_functions/README.md
T
2021-12-29 00:06:08 +08:00

78 lines
1.7 KiB
Markdown

resty里请求域名地址时无法使用本地的`/etc/hosts`文件,需在`nginx.conf`文件中的`http`模块内添加`resolver`配置显式指定:
```nginx
http {
...
resolver 8.8.8.8;
...
}
```
put `upload.lua` into:
```bash
/usr/local/opt/openresty/nginx/resty_funcs
```
post file:
```bash
$ 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:
```bash
➤ which openresty 20:17:35
/usr/local/bin/openresty
```
Configuration:
```bash
pwd 20:17:57
/usr/local/opt/openresty
```
```bash
pwd 20:20:00
/usr/local/opt/openresty/nginx/resty_funcs
```
Update:
```bash
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
```