我的nginx.conf跟Lua代码,你可以稍作修改试一下
在 2018年8月31日星期五 UTC+8下午12:42:37,tokers写道:
Attachment:
checkDB.lua
Description: Binary data
user nobody;
worker_processes auto;
error_log logs/error.log;
#pid logs/nginx.pid;
events {
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format app '"$remote_addr" "$remote_user" "[$time_local]" "$request" "$status" "$body_bytes_sent" "$http_referer" "$http_user_agent" "$request_method $scheme://$host$request_uri" "$host" "$http_x_forwarded_for" "$request_time" "$remote_port" "$upstream_response_time" "$http_x_readtime" "$uri" "$upstream_status" "$upstream_addr" "$cookie_nuid" "$request_id"';
#access_log logs/access.log app;
access_log off;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml application/json;
gzip_vary on;
lua_package_path "/opt/app/nginx_heart/lualib/?.lua;;";
init_worker_by_lua_file /opt/app/nginx_heart/checkDB.lua;
lua_shared_dict databases 12k;
server {
listen 8899;
server_name localhost;
resolver 10.5.0.4 10.6.0.4;
location / {
root html;
index index.html index.htm;
}
location /log/new/10001 {
content_by_lua_file /opt/app/nginx_heart/monitMysql.lua;
}
location /heart/new/10001 {
content_by_lua_file /opt/app/nginx_heart/monitRedis.lua;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}