diff --git a/extend/base/admin/service/adminInitData/SystemMenu.php b/extend/base/admin/service/adminInitData/SystemMenu.php index 6a26cab..db39412 100644 --- a/extend/base/admin/service/adminInitData/SystemMenu.php +++ b/extend/base/admin/service/adminInitData/SystemMenu.php @@ -209,6 +209,50 @@ $ul_system_menu = array( "sort" => 0, "status" => 1, ), + array( + "id" => 300, + "pid" => 0, + "title" => "Nginx 日志分析", + "icon" => "fa fa-chart-bar", + "href" => "", + "params" => "", + "target" => "_self", + "sort" => 0, + "status" => 1, + ), + array( + "id" => 301, + "pid" => 300, + "title" => "访问统计仪表盘", + "icon" => "fa fa-line-chart", + "href" => "system.nginx_log_stat/index", + "params" => "", + "target" => "_self", + "sort" => 0, + "status" => 1, + ), + array( + "id" => 302, + "pid" => 300, + "title" => "原始访问日志", + "icon" => "fa fa-file-text", + "href" => "system.nginx_access_log/index", + "params" => "", + "target" => "_self", + "sort" => 0, + "status" => 1, + ), + array( + "id" => 303, + "pid" => 300, + "title" => "读取位置管理", + "icon" => "fa fa-map-marker", + "href" => "system.nginx_log_position/index", + "params" => "", + "target" => "_self", + "sort" => 0, + "status" => 1, + ), ); diff --git a/source/stack/docker-dev-sync/source/docker/nginx-log-format.conf b/source/stack/docker-dev-sync/source/docker/nginx-log-format.conf new file mode 100644 index 0000000..b7fc334 --- /dev/null +++ b/source/stack/docker-dev-sync/source/docker/nginx-log-format.conf @@ -0,0 +1,6 @@ +# ulthon_admin nginx_log 分析专用 log_format +# 必须放在 nginx 的 http 块(通过 conf.d/*.conf 自动 include) +log_format analytics '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $body_bytes_sent ' + '"$http_referer" "$http_user_agent" ' + '$request_time $upstream_response_time $bytes_sent'; diff --git a/source/stack/docker-dev-sync/source/docker/nginx.conf b/source/stack/docker-dev-sync/source/docker/nginx.conf index 801249e..8f100ba 100644 --- a/source/stack/docker-dev-sync/source/docker/nginx.conf +++ b/source/stack/docker-dev-sync/source/docker/nginx.conf @@ -14,6 +14,9 @@ server { # 运行时长不限制 fastcgi_read_timeout 60000; + # ulthon_admin nginx_log 分析:access_log 写到 runtime(持久化 + PHP 必能读) + access_log /var/www/html/runtime/nginx/access.log analytics; + location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; diff --git a/source/stack/docker-dev-sync/source/docker/run.sh b/source/stack/docker-dev-sync/source/docker/run.sh index 8b32241..c7b424b 100644 --- a/source/stack/docker-dev-sync/source/docker/run.sh +++ b/source/stack/docker-dev-sync/source/docker/run.sh @@ -50,6 +50,12 @@ mkdir -p /var/www/html/public/build && chmod -R 777 /var/www/html/public/build mkdir -p /var/www/html/storage && chmod -R 777 /var/www/html/storage mkdir -p /var/www/html/memoryspace && chown -R www-data:www-data /var/www/html/memoryspace +# 复制 nginx_log 分析的 log_format 配置到 nginx http 块(conf.d 自动 include) +cp "$SCRIPT_DIR/nginx-log-format.conf" /etc/nginx/conf.d/ + +# 创建 nginx access_log 目录(必须在 service nginx start 之前) +mkdir -p /var/www/html/runtime/nginx && chmod 777 /var/www/html/runtime/nginx + # ---- Step 4: Output parameters and start services ---- echo "参数为:$@" diff --git a/source/stack/docker-dev/source/docker/nginx-log-format.conf b/source/stack/docker-dev/source/docker/nginx-log-format.conf new file mode 100644 index 0000000..b7fc334 --- /dev/null +++ b/source/stack/docker-dev/source/docker/nginx-log-format.conf @@ -0,0 +1,6 @@ +# ulthon_admin nginx_log 分析专用 log_format +# 必须放在 nginx 的 http 块(通过 conf.d/*.conf 自动 include) +log_format analytics '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $body_bytes_sent ' + '"$http_referer" "$http_user_agent" ' + '$request_time $upstream_response_time $bytes_sent'; diff --git a/source/stack/docker-dev/source/docker/nginx.conf b/source/stack/docker-dev/source/docker/nginx.conf index 801249e..8f100ba 100644 --- a/source/stack/docker-dev/source/docker/nginx.conf +++ b/source/stack/docker-dev/source/docker/nginx.conf @@ -14,6 +14,9 @@ server { # 运行时长不限制 fastcgi_read_timeout 60000; + # ulthon_admin nginx_log 分析:access_log 写到 runtime(持久化 + PHP 必能读) + access_log /var/www/html/runtime/nginx/access.log analytics; + location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; diff --git a/source/stack/docker-dev/source/docker/run.sh b/source/stack/docker-dev/source/docker/run.sh index 21d57a6..e900734 100644 --- a/source/stack/docker-dev/source/docker/run.sh +++ b/source/stack/docker-dev/source/docker/run.sh @@ -24,6 +24,13 @@ mkdir -p /var/www/html/storage && chmod -R 777 /var/www/html/storage mkdir -p /var/www/html/memoryspace && chown -R www-data:www-data /var/www/html/memoryspace +# 复制 nginx_log 分析的 log_format 配置到 nginx http 块(conf.d 自动 include) +cp "$SCRIPT_DIR/nginx-log-format.conf" /etc/nginx/conf.d/ + +# 创建 nginx access_log 目录(必须在 service nginx start 之前) +mkdir -p /var/www/html/runtime/nginx && chmod 777 /var/www/html/runtime/nginx + + # 运行redis # nohup redis-server --requirepass "" & diff --git a/source/stack/docker-serve/source/docker/nginx-log-format.conf b/source/stack/docker-serve/source/docker/nginx-log-format.conf new file mode 100644 index 0000000..b7fc334 --- /dev/null +++ b/source/stack/docker-serve/source/docker/nginx-log-format.conf @@ -0,0 +1,6 @@ +# ulthon_admin nginx_log 分析专用 log_format +# 必须放在 nginx 的 http 块(通过 conf.d/*.conf 自动 include) +log_format analytics '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $body_bytes_sent ' + '"$http_referer" "$http_user_agent" ' + '$request_time $upstream_response_time $bytes_sent'; diff --git a/source/stack/docker-serve/source/docker/nginx.conf b/source/stack/docker-serve/source/docker/nginx.conf index 801249e..8f100ba 100644 --- a/source/stack/docker-serve/source/docker/nginx.conf +++ b/source/stack/docker-serve/source/docker/nginx.conf @@ -14,6 +14,9 @@ server { # 运行时长不限制 fastcgi_read_timeout 60000; + # ulthon_admin nginx_log 分析:access_log 写到 runtime(持久化 + PHP 必能读) + access_log /var/www/html/runtime/nginx/access.log analytics; + location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; diff --git a/source/stack/docker-serve/source/docker/run.sh b/source/stack/docker-serve/source/docker/run.sh index c7630eb..fe2324c 100644 --- a/source/stack/docker-serve/source/docker/run.sh +++ b/source/stack/docker-serve/source/docker/run.sh @@ -20,6 +20,13 @@ mkdir -p /var/www/html/storage && chmod -R 777 /var/www/html/storage mkdir -p /var/www/html/memoryspace && chown -R www-data:www-data /var/www/html/memoryspace +# 复制 nginx_log 分析的 log_format 配置到 nginx http 块(conf.d 自动 include) +cp "$SCRIPT_DIR/nginx-log-format.conf" /etc/nginx/conf.d/ + +# 创建 nginx access_log 目录(必须在 service nginx start 之前) +mkdir -p /var/www/html/runtime/nginx && chmod 777 /var/www/html/runtime/nginx + + # 运行redis # nohup redis-server --requirepass "" & diff --git a/source/stack/full/source/docker/nginx-log-format.conf b/source/stack/full/source/docker/nginx-log-format.conf new file mode 100644 index 0000000..b7fc334 --- /dev/null +++ b/source/stack/full/source/docker/nginx-log-format.conf @@ -0,0 +1,6 @@ +# ulthon_admin nginx_log 分析专用 log_format +# 必须放在 nginx 的 http 块(通过 conf.d/*.conf 自动 include) +log_format analytics '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $body_bytes_sent ' + '"$http_referer" "$http_user_agent" ' + '$request_time $upstream_response_time $bytes_sent'; diff --git a/source/stack/full/source/docker/nginx.conf b/source/stack/full/source/docker/nginx.conf index 801249e..8f100ba 100644 --- a/source/stack/full/source/docker/nginx.conf +++ b/source/stack/full/source/docker/nginx.conf @@ -14,6 +14,9 @@ server { # 运行时长不限制 fastcgi_read_timeout 60000; + # ulthon_admin nginx_log 分析:access_log 写到 runtime(持久化 + PHP 必能读) + access_log /var/www/html/runtime/nginx/access.log analytics; + location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; diff --git a/source/stack/full/source/docker/run.sh b/source/stack/full/source/docker/run.sh index c7630eb..fe2324c 100644 --- a/source/stack/full/source/docker/run.sh +++ b/source/stack/full/source/docker/run.sh @@ -20,6 +20,13 @@ mkdir -p /var/www/html/storage && chmod -R 777 /var/www/html/storage mkdir -p /var/www/html/memoryspace && chown -R www-data:www-data /var/www/html/memoryspace +# 复制 nginx_log 分析的 log_format 配置到 nginx http 块(conf.d 自动 include) +cp "$SCRIPT_DIR/nginx-log-format.conf" /etc/nginx/conf.d/ + +# 创建 nginx access_log 目录(必须在 service nginx start 之前) +mkdir -p /var/www/html/runtime/nginx && chmod 777 /var/www/html/runtime/nginx + + # 运行redis # nohup redis-server --requirepass "" &