我正在尝试在 CentOS 6 上使用Apache Traffic Server (ATS)设置具有基本代理身份验证的转发代理服务器。我已经成功部署了具有基本代理身份验证的SQUID和Apache httpd mod_proxy转发代理,并且想做与 ATS 相同以比较性能。
我正在尝试使用ATS 提供的basic-auth插件示例,但存在多个问题。
我为 CentOS 6 添加了最新的 epel repo 并安装了 trafficserver 和 trafficserver-devel(需要使用 ATS 编译器tsxs)软件包。我将 basic-auth.c 文件从源代码复制到我的用户目录并尝试编译:
# tsxs -v -o /root/basic-auth.so -c /root/basic-auth.c
因此,我收到未找到文件的错误-ts/ink_defs.h
这个文件是通过在源代码上运行autoconfig -if
和生成的configure
——所以我继续克隆了 trafficserver git repo 并运行了在/opt/ts/
. 我将这些复制到tsxs查看的目录 - /usr/include/ts/
(这里是因为它是使用trafficserver-devel安装时的默认位置(当我以前只从源安装流量服务器时,tsxs不会运行)。
现在文件就位后,我再次在 basic-auth.cc 上运行编译器。这次我收到错误ts.h
,因为 sdk_version 参数:
# tsxs -v -o basic-auth.so basic-auth.c
compiling basic-auth.c -> basic-auth.lo
cc -I/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -feliminate-unused-debug-symbols -fno-strict-aliasing -mcx16 -fpic -c basic-auth.c -o basic-auth.lo
In file included from basic-auth.c:30:
/usr/include/ts/ts.h:158: error: expected ‘)’ before ‘sdk_version’
In file included from /usr/include/ts/ink_defs.h:28,
from basic-auth.c:31:
/usr/include/ts/ink_config.h:41:26: error: ink_autoconf.h: No such file or directory
basic-auth.c: In function ‘TSPluginInit’:
basic-auth.c:222: warning: implicit declaration of function ‘TSPluginRegister’
tsxs: compilation failed: cc -I/usr/include -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -feliminate-unused-debug-symbols -fno-strict-aliasing -mcx16 -fpic -c basic-auth.c -o basic-auth.lo
我调查了代码ts.h
并将其与最新的源代码进行了比较。您可以看到第 156 行发生了变化:
交通服务器开发:
tsapi TSReturnCode TSPluginRegister(TSSDKVersion sdk_version, TSPluginRegistrationInfo plugin_info);
资源:
tsapi TSReturnCode TSPluginRegister(TSPluginRegistrationInfo *plugin_info);
因此,我假设版本控制存在一些问题。我用最新的源代码替换了我的 ts.h 版本并再次尝试编译:它有效!
我将 .so 文件复制到插件目录并相应地修改 plugins.config 和 records.config。唉,当我尝试启动 trafficserver 时,它因分段错误而失败:
# /usr/bin/traffic_server
traffic_server: using root directory '/usr'
[Jul 15 16:19:21.224] Server {0x7fd9458ba7e0} DEBUG: (dns) ink_dns_init: called with init_called = 0
[Jul 15 16:19:21.227] Server {0x7fd9458ba7e0} DEBUG: (dns) localhost=vmProxy1
[Jul 15 16:19:21.227] Server {0x7fd9458ba7e0} DEBUG: (dns) Round-robin nameservers = 1
traffic_server: Segmentation fault (Signal sent by the kernel [(nil)])traffic_server - STACK TRACE:
/usr/bin/traffic_server(_Z19crash_logger_invokeiP7siginfoPv+0x99)[0x4a5209]
/lib64/libpthread.so.0[0x35b600f710]
/lib64/libc.so.6[0x35b5d3362f]
/usr/lib64/trafficserver/libtsutil.so.5(_xstrdup+0x6d)[0x7fd945f2b6cd]
/usr/bin/traffic_server(TSPluginRegister+0x7c)[0x4bcb6c]
/usr/lib64/trafficserver/plugins/basic-auth.so(TSPluginInit+0x2f)[0x7fd942334e1f]
/usr/bin/traffic_server(_Z11plugin_initb+0x322)[0x4dab22]
/usr/bin/traffic_server(main+0x1424)[0x4d2754]
/lib64/libc.so.6(__libc_start_main+0xfd)[0x35b5c1ed5d]
/usr/bin/traffic_server[0x4942a9]
Segmentation fault (core dumped)
我尝试使用 gdb 来获得更好的调试日志,但我没有看到任何有用的东西。还有另一个提到sdk_version
- 但我开始认为在文件中跳转并替换它们并不是它的工作方式......
Starting program: /usr/bin/traffic_server
[Thread debugging using libthread_db enabled]
traffic_server: using root directory '/usr'
[New Thread 0x7ffff7704700 (LWP 19967)]
[Jul 15 16:18:28.841] Server {0x7ffff77777e0} DEBUG: (dns) ink_dns_init: called with init_called = 0
[New Thread 0x7ffff68ff700 (LWP 19968)]
[New Thread 0x7ffff67fe700 (LWP 19969)]
[Jul 15 16:18:28.844] Server {0x7ffff77777e0} DEBUG: (dns) localhost=vmProxy1
[Jul 15 16:18:28.844] Server {0x7ffff77777e0} DEBUG: (dns) Round-robin nameservers = 1
[New Thread 0x7ffff46f5700 (LWP 19970)]
[New Thread 0x7ffff44f3700 (LWP 19971)]
Program received signal SIGSEGV, Segmentation fault.
__strlen_sse42 () at ../sysdeps/x86_64/multiarch/strlen-sse4.S:32
32 pcmpeqb (%rdi), %xmm1
Missing separate debuginfos, use: debuginfo-install tcl-8.5.7-6.el6.x86_64
(gdb) bt
#0 __strlen_sse42 () at ../sysdeps/x86_64/multiarch/strlen-sse4.S:32
#1 0x00007ffff7de86cd in _xstrdup (str=0xd46e3934ae7d6389 <Address 0xd46e3934ae7d6389 out of bounds>, length=-1)
at ink_memory.cc:231
#2 0x00000000004bcb6c in TSPluginRegister (sdk_version=<value optimized out>, plugin_info=0x7fffffffcc50)
at InkAPI.cc:1803
#3 0x00007ffff41f1e1f in TSPluginInit (argc=<value optimized out>, argv=<value optimized out>) at /root/basic-auth.c:222
#4 0x00000000004dab22 in plugin_load (validateOnly=false) at Plugin.cc:114
#5 plugin_init (validateOnly=false) at Plugin.cc:265
#6 0x00000000004d2754 in main (argv=<value optimized out>) at Main.cc:1714
非常感谢任何关于我可能做错的提示或提示。