产品动态
发行版 | 版本 | 架构 |
Ubuntu | 20.04、22.04、24.04、24.10 | x86_64、aarch64/arm64 |
RHEL 及其衍生版(CentOS 等) | 8.x、9.x | x86_64、aarch64/arm64 |
Alpine | 3.18、3.19、3.20、3.21 | x86_64、aarch64/arm64 |
Debian | 11.x、12.x | x86_64、aarch64/arm64 |
SLES | 15 SP2+ | x86_64 |
nginx -V
nginx version: nginx/1.26.2built by gcc 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)built with OpenSSL 3.0.2 15 Mar 2022TLS SNI support enabledconfigure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.26.2/debian/debuild-base/nginx-1.26.2=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'

wget https://github.com/nginx/nginx/archive/refs/tags/release-1.26.2.zipunzip release-1.26.2.zip
configure命令后加上前面记录的 configure 参数。cd nginx-release-1.26.2auto/configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.26.2/debian/debuild-base/nginx-1.26.2=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'
git clone https://github.com/nginxinc/nginx-otel.git
cd nginx-otelmkdir buildcd build
/path/to/configured/nginx/objs 是之前生成的 Nginx 编译文件中 objs文件夹的路径,可以在 Nginx 源码文件夹中找到。cmake -DNGX_OTEL_NGINX_BUILD_DIR=/path/to/configured/nginx/objs ..make
nginx-otel/build 文件夹下生成动态模块文件 ngx_otel_module.so,以下是 nginx-otel/build 文件夹下的所有文件示例。CMakeCache.txt CMakeFiles cmake_install.cmake _deps gens http_archives Makefile ngx_otel_module.so opentelemetry protos
ngx_otel_module.so 文件移动到 /etc/nginx/modules 文件夹下(本文使用 Ubuntu 系统中 Nginx 的配置路径,其他系统的配置路径可能不同)。mvngx_otel_module.so /etc/nginx/modules
/etc/nginx/nginx.conf。load_module modules/ngx_otel_module.so; # 加载动态模块...http {...otel_exporter {endpoint ${ENDPOINT}; # APM 接入点}otel_trace on; # 开启链路追踪otel_service_name ${SERVICE_NAME}; # APM 应用名otel_trace_context propagate; # 将 W3C 请求头注入 TraceID,需要启用otel_resource_attr token ${TOKEN}; # 接入 tokenotel_resource_attr host.name ${HOST.NAME}; # 实例的主机名...}
nginx。sudo nginx -s reload 重新加载配置文件,或者通过 service nginx restart 重启 Nginx 服务,即可完成接入。文档反馈