#user nobody;
worker_processes 8;
daemon off;
# pid logs/nginx.pid;
events {
worker_connections 65535;
}
http {
include mime.types;
default_type application/json;
log_format main escape=json '[$log_time] [$logid] [INFO] $log_info';
access_log logs/access.log main;
sendfile on;
log_escape_non_ascii off;
lua_package_path "lua/?.lua;;";
# 在init中调用seed函数,确保生成uuid全局唯一
init_worker_by_lua_block {
local uuid = require ("jit_uuid")
uuid.seed()
}
server {
listen 8087;
server_name localhost;
lua_need_request_body on;
lua_code_cache on;
# 4k限制时没有如下两行
client_body_buffer_size 256k;
client_max_body_size 256k;
location /click {
set $log_info '';
set $logid '';
set $log_time '';
content_by_lua_block {
local log = require("log")
local uuid = require ("jit_uuid")
ngx.var.logid = uuid()
ngx.var.log_time = ngx.localtime()
ngx.var.log_info = log:log()
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}