mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
fb5a4e5b59
OpenResty 日志输出 $upstream_cache_status;Agent/协议/ClickHouse 贯通入库。 明细列表与详情按 HIT/MISS 等推导命中、回源、未缓存三态标签。
67 lines
3.1 KiB
Go
67 lines
3.1 KiB
Go
// Copyright 2026 Arctel.net
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package model
|
|
|
|
import "time"
|
|
|
|
// OpenFlareOption is the key/value DTO used by the OpenFlare option API surface.
|
|
// Key 与 w_system_configs.key 一致(snake_case)。此类型仅作为
|
|
// /api/v1/d/option 接口的请求/响应载体,不再映射到独立的 of_options 表。
|
|
type OpenFlareOption struct {
|
|
Key string `json:"key"`
|
|
Value string `json:"value"`
|
|
}
|
|
|
|
// StartTime records process start time (seconds) for the public /status endpoint.
|
|
var StartTime = time.Now().Unix()
|
|
|
|
// DefaultOpenRestyMainConfigTemplate 是 OpenResty 主配置模板的内置默认值。
|
|
// 当 SystemConfig 中缺失 openresty_main_config_template 时作为兜底使用。
|
|
const DefaultOpenRestyMainConfigTemplate = `# This file is generated by OpenFlare. Do not edit manually.
|
|
user openflare;
|
|
worker_processes {{OpenRestyWorkerProcesses}};
|
|
worker_rlimit_nofile {{OpenRestyWorkerRlimitNofile}};
|
|
pid __OPENFLARE_PID_PATH__;
|
|
error_log {{OpenRestyErrorLogPath}} warn;
|
|
|
|
events {
|
|
worker_connections {{OpenRestyWorkerConnections}};
|
|
{{OpenRestyEventsUseDirective}}{{OpenRestyEventsMultiAcceptDirective}}}
|
|
|
|
http {
|
|
include mime.types;
|
|
default_type application/octet-stream;
|
|
server_tokens off;
|
|
client_body_temp_path __OPENFLARE_NGINX_CACHE_DIR__/client_temp;
|
|
proxy_temp_path __OPENFLARE_NGINX_CACHE_DIR__/proxy_temp;
|
|
fastcgi_temp_path __OPENFLARE_NGINX_CACHE_DIR__/fastcgi_temp;
|
|
uwsgi_temp_path __OPENFLARE_NGINX_CACHE_DIR__/uwsgi_temp;
|
|
scgi_temp_path __OPENFLARE_NGINX_CACHE_DIR__/scgi_temp;
|
|
{{OpenRestyConnectionUpgradeMap}}{{OpenRestyDefaultServerBlock}} log_format openflare_json escape=json '{"ts":"$time_iso8601","host":"$host","path":"$request_uri","remote_addr":"$remote_addr","status":$status,"request_time":$request_time,"bytes_sent":$body_bytes_sent,"request_length":$request_length,"user_agent":"$http_user_agent","cache_status":"$upstream_cache_status"}';
|
|
access_log {{OpenRestyAccessLogPath}} openflare_json;
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_timeout {{OpenRestyKeepaliveTimeout}};
|
|
keepalive_requests {{OpenRestyKeepaliveRequests}};
|
|
client_header_timeout {{OpenRestyClientHeaderTimeout}};
|
|
client_body_timeout {{OpenRestyClientBodyTimeout}};
|
|
client_max_body_size {{OpenRestyClientMaxBodySize}};
|
|
large_client_header_buffers {{OpenRestyLargeClientHeaderBuffers}};
|
|
send_timeout {{OpenRestySendTimeout}};
|
|
proxy_connect_timeout {{OpenRestyProxyConnectTimeout}};
|
|
proxy_send_timeout {{OpenRestyProxySendTimeout}};
|
|
proxy_read_timeout {{OpenRestyProxyReadTimeout}};
|
|
proxy_request_buffering {{OpenRestyProxyRequestBuffering}};
|
|
proxy_buffering {{OpenRestyProxyBuffering}};
|
|
proxy_buffers {{OpenRestyProxyBuffers}};
|
|
proxy_buffer_size {{OpenRestyProxyBufferSize}};
|
|
proxy_busy_buffers_size {{OpenRestyProxyBusyBuffersSize}};
|
|
gzip {{OpenRestyGzip}};
|
|
gzip_min_length {{OpenRestyGzipMinLength}};
|
|
gzip_comp_level {{OpenRestyGzipCompLevel}};
|
|
{{OpenRestyResolverDirective}}{{OpenRestyCacheBlock}} include {{OpenRestyRouteConfigInclude}};
|
|
}
|
|
`
|