100 lines
3.0 KiB
Nginx Configuration File
100 lines
3.0 KiB
Nginx Configuration File
|
|
worker_processes 1;
|
||
|
|
error_log logs/error.log info;
|
||
|
|
events {
|
||
|
|
worker_connections 1024;
|
||
|
|
}
|
||
|
|
http {
|
||
|
|
#Lua file path
|
||
|
|
#;; means openresty default path
|
||
|
|
lua_package_path "/Users/liyong/Code/Lua/lua-rest/openresty/conf/lua/?.lua;;";
|
||
|
|
lua_package_cpath "/Users/liyong/Code/Lua/lua-rest/openresty/conf/c_ffi/add/?.so;;";
|
||
|
|
|
||
|
|
#Only use for debug
|
||
|
|
# lua_code_cache off;
|
||
|
|
|
||
|
|
server {
|
||
|
|
listen 8080; #Listen port
|
||
|
|
|
||
|
|
#Upload json file
|
||
|
|
set $store_dir "/Users/liyong/Code/Lua/lua-rest/openresty/conf/upload_files/"; # 文件存储路径
|
||
|
|
|
||
|
|
#Default location
|
||
|
|
location / {
|
||
|
|
default_type text/html;
|
||
|
|
content_by_lua_block {
|
||
|
|
ngx.say("Default location")
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#Read body
|
||
|
|
# lua_need_request_body on;
|
||
|
|
location /test_get_body {
|
||
|
|
content_by_lua_block {
|
||
|
|
local data = ngx.req.get_body_data()
|
||
|
|
ngx.say("hello ", data)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
client_body_in_file_only on;
|
||
|
|
location /test {
|
||
|
|
content_by_lua_block {
|
||
|
|
function getFile(file_name)
|
||
|
|
local f = assert(io.open(file_name, 'r'))
|
||
|
|
local string = f:read("*all")
|
||
|
|
f:close()
|
||
|
|
return string
|
||
|
|
end
|
||
|
|
|
||
|
|
ngx.req.read_body()
|
||
|
|
local data = ngx.req.get_body_data()
|
||
|
|
if nil == data then
|
||
|
|
local file_name = ngx.req.get_body_file()
|
||
|
|
ngx.say(">> temp file: ", file_name)
|
||
|
|
if file_name then
|
||
|
|
data = getFile(file_name)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
ngx.say("hello ", data)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#C FFI
|
||
|
|
location /c_ffi {
|
||
|
|
content_by_lua_file /Users/liyong/Code/Lua/lua-rest/openresty/conf/c_ffi/add/test_ffi_temp_file.lua;
|
||
|
|
}
|
||
|
|
|
||
|
|
#Upload json file
|
||
|
|
location /upload_json_file {
|
||
|
|
content_by_lua_file /Users/liyong/Code/Lua/lua-rest/openresty/conf/lua/upload_json_file.lua;
|
||
|
|
}
|
||
|
|
|
||
|
|
#Upload image file
|
||
|
|
location /upload_image {
|
||
|
|
content_by_lua_file /Users/liyong/Code/Lua/lua-rest/openresty/conf/lua/upload_image.lua;
|
||
|
|
}
|
||
|
|
|
||
|
|
#Upload dir
|
||
|
|
location /append_file_output {
|
||
|
|
default_type "";
|
||
|
|
alias /Users/liyong/Code/Lua/lua-rest/openresty/conf/upload_files;
|
||
|
|
autoindex on;
|
||
|
|
autoindex_exact_size off;
|
||
|
|
autoindex_localtime on;
|
||
|
|
}
|
||
|
|
|
||
|
|
#Set and get redis
|
||
|
|
location /set_get_redis {
|
||
|
|
content_by_lua_file /Users/liyong/Code/Lua/lua-rest/openresty/conf/lua/set_and_get_redis.lua;
|
||
|
|
}
|
||
|
|
|
||
|
|
#Get image append task status
|
||
|
|
location = /get_image_append_task_status {
|
||
|
|
content_by_lua_file /Users/liyong/Code/Lua/lua-rest/openresty/conf/lua/get_image_append_task_status.lua;
|
||
|
|
}
|
||
|
|
|
||
|
|
#Other locations
|
||
|
|
include extra/*.conf;
|
||
|
|
}
|
||
|
|
}
|