Skip to content

How to compile and test this module on openresty?

Xiaochen Wang edited this page Jul 14, 2022 · 3 revisions

download

wget https://openresty.org/download/openresty-1.21.4.1.tar.gz
tar xvf openresty-1.21.4.1.tar.gz
cd openresty-1.21.4.1.tar.gz

compile

DESKTOP-CQEO1JN openresty-1.21.4.1 $  ./configure --add-module=../ngx_http_proxy_connect_module/

patch

DESKTOP-CQEO1JN openresty-1.21.4.1 $ patch -d build/nginx-1.21.4/ -p 1 < ../ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_102101.patch
patching file src/http/ngx_http_core_module.c
Hunk #1 succeeded at 967 (offset 10 lines).
patching file src/http/ngx_http_parse.c
patching file src/http/ngx_http_request.c
Hunk #1 succeeded at 1106 (offset -12 lines).
Hunk #2 succeeded at 1744 (offset -12 lines).
Hunk #3 succeeded at 2071 (offset -4 lines).
patching file src/http/ngx_http_request.h
Hunk #1 succeeded at 414 (offset 3 lines).
patching file src/http/ngx_http_variables.c

make

DESKTOP-CQEO1JN openresty-1.21.4.1 $ make
...
...
sr/local/openresty/luajit/lib -Wl,-rpath,/usr/local/openresty/luajit/lib -Wl,--require-defined=pcre_version -Wl,-E -Wl,-E -ldl -lpthread -lcrypt -L/home/xiaochen/work/openresty-1.21.4.1/build/luajit-root/usr/local/openresty/luajit/lib -lluajit-5.1 -lm -ldl -L/home/xiaochen/work/openresty-1.21.4.1/build/luajit-root/usr/local/openresty/luajit/lib -lluajit-5.1 -lm -ldl -lpcre -lssl -lcrypto -ldl -lpthread -lz \
-Wl,-E
sed -e "s|%%PREFIX%%|/usr/local/openresty/nginx|" \
        -e "s|%%PID_PATH%%|/usr/local/openresty/nginx/logs/nginx.pid|" \
        -e "s|%%CONF_PATH%%|/usr/local/openresty/nginx/conf/nginx.conf|" \
        -e "s|%%ERROR_LOG_PATH%%|/usr/local/openresty/nginx/logs/error.log|" \
        < docs/man/nginx.8 > objs/nginx.8
make[2]: Leaving directory '/home/xiaochen/work/openresty-1.21.4.1/build/nginx-1.21.4'
make[1]: Leaving directory '/home/xiaochen/work/openresty-1.21.4.1/build/nginx-1.21.4'

install

*!!! You must install currensty resty.core from openresty to local /usr/local/openresty/, otherwise the nginx binary will report error when you run test case.

DESKTOP-CQEO1JN openresty-1.21.4.1 $ make install

run test case

  • fix tested nginx binary path
DESKTOP-CQEO1JN openresty-1.21.4.1 $ cd ../ngx_http_proxy_connect_module/
DESKTOP-CQEO1JN ngx_http_proxy_connect_module $ vim t/runtest.sh
nginx_binary=/home/xiaochen/work/openresty-1.21.4.1/build/nginx-1.21.4/objs/nginx
^------------ fix this line to ur openresty nginx binary path
  • run tst case
DESKTOP-CQEO1JN ngx_http_proxy_connect_module $ sh t/runtest.sh
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect.t .................... Use of uninitialized value $1 in split at /home/xiaochen/work/nginx-tests/lib/Test/Nginx.pm line 257.
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect.t .................... 1/? Use of uninitialized value $1 in split at /home/xiaochen/work/nginx-tests/lib/Test/Nginx.pm line 257.
Use of uninitialized value $1 in split at /home/xiaochen/work/nginx-tests/lib/Test/Nginx.pm line 257.
Use of uninitialized value $1 in split at /home/xiaochen/work/nginx-tests/lib/Test/Nginx.pm line 257.
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect.t .................... 18/? Use of uninitialized value $1 in split at /home/xiaochen/work/nginx-tests/lib/Test/Nginx.pm line 257.
        (in cleanup)    (in cleanup)  at /usr/share/perl/5.30/Test2/API.pm line 174 during global destruction.
                                                                           /home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect.t .................... ok
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_lua.t ................ Use of uninitialized value $1 in split at /home/xiaochen/work/nginx-tests/lib/Test/Nginx.pm line 257.
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_lua.t ................ 1/?  (in cleanup)    (in cleanup)  at /usr/share/perl/5.30/Test2/API.pm line 174 during global destruction.
                                                                           /home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_lua.t ................ ok
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_resolve_variables.t .. Use of uninitialized value $1 in split at /home/xiaochen/work/nginx-tests/lib/Test/Nginx.pm line 257.
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_resolve_variables.t .. 1/?  (in cleanup)    (in cleanup)  at /usr/share/perl/5.30/Test2/API.pm line 174 during global destruction.
                                                                           /home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_resolve_variables.t .. ok
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_timeout.t ............ Use of uninitialized value $1 in split at /home/xiaochen/work/nginx-tests/lib/Test/Nginx.pm line 257.
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_timeout.t ............ 1/?  (in cleanup)    (in cleanup)  at /usr/share/perl/5.30/Test2/API.pm line 174 during global destruction.
                                                                           /home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_timeout.t ............ ok
All tests successful.

Test Summary Report
-------------------
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_resolve_variables.t (Wstat: 0 Tests: 6 Failed: 0)
  TODO passed:   1-2
/home/xiaochen/work/ngx_http_proxy_connect_module/t/http_proxy_connect_timeout.t          (Wstat: 0 Tests: 5 Failed: 0)
  TODO passed:   1-3
Files=4, Tests=34,  3 wallclock secs ( 0.00 usr  0.05 sys +  0.28 cusr  0.87 csys =  1.20 CPU)
Result: PASS