Skip to content

nginx: [emerg] unknown directive "proxy_connect"  #236

Closed
@Lixxcn

Description

@Lixxcn

Hello, I need your help, there is a similar problem in the Issue, but I still can't solve it, you can help me to see where the problem is.

The following is my operation, the log.

cd nginx-1.22.0
sudo patch -p1 </home/deployer/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_102101.patch
sudo ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/home/deployer/ngx_http_proxy_connect_module
sudo make && sudo make install
sudo nginx -V
sudo nginx -s reload
sudo nginx -t
image

[User_login@host-172-25-4-37 ~]$ su - deployer
密码:
上一次登录:三 8月 24 16:53:38 CST 2022pts/0 上
[deployer@host-172-25-4-37 ~]$ ll
总用量 4558212
drwxrwxr-x  2 deployer    deployer            96 8月  24 15:33 bak
-rw-rw-r--  1 LTcontroler LTcontroler 4664066048 12月 28 2020 CentOS-7-x86_64-DVD-1908.iso
-rw-rw-r--  1 deployer    deployer          9285 8月  25 2021 Linux_配置规范_S3A1G3.zip
drwxr-xr-x  9 deployer    deployer           186 4月  25 18:57 nginx-1.21.0
drwxr-xr-x  9 deployer    deployer           186 8月  24 16:04 nginx-1.21.6
-rw-r--r--  1 deployer    deployer       1073364 8月  24 16:03 nginx-1.21.6.tar.gz
drwxr-xr-x 10 deployer    deployer           199 8月  24 16:43 nginx-1.22.0
-rw-r--r--  1 deployer    deployer       1073322 8月  11 17:30 nginx-1.22.0.tar.gz
drwxr-xr-x  9 deployer    deployer           186 8月  24 16:54 nginx-1.23.1
-rw-r--r--  1 User_login  User_login     1104352 8月  11 17:48 nginx-1.23.1.tar.gz
drwxrwxr-x  6 deployer    deployer           140 8月  16 17:26 ngx_http_proxy_connect_module
drwxrwxr-x  5 deployer    deployer           145 8月  12 20:31 ngx_http_proxy_connect_module-master
-rw-r--r--  1 deployer    deployer        255250 8月  24 15:34 ngx_http_proxy_connect_module.zip
drwxrwxr-x  6 deployer    deployer           231 9月   9 2021 packages
drwxrwxr-x  3 deployer    deployer            84 8月  16 17:33 proxy
drwxrwxr-x  2 deployer    deployer           118 8月  25 2021 secure
-rw-r--r--  1 deployer    deployer          1704 6月  28 15:04 server.key
-rw-r--r--  1 deployer    deployer          5641 6月  28 15:05 server.pem
drwxrwxr-x  4 deployer    deployer           115 8月  12 20:51 test
[deployer@host-172-25-4-37 ~]$ cd nginx-1.22.0
[deployer@host-172-25-4-37 nginx-1.22.0]$ ls
auto  CHANGES  CHANGES.ru  clean  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src
[deployer@host-172-25-4-37 nginx-1.22.0]$ sudo make clean
rm -rf Makefile objs
[deployer@host-172-25-4-37 nginx-1.22.0]$ sudo patch -p1 </home/deployer/ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_102101.patch
(Stripping trailing CRs from patch; use --binary to disable.)
patching file src/http/ngx_http_core_module.c
Hunk #1 succeeded at 964 (offset 7 lines).
(Stripping trailing CRs from patch; use --binary to disable.)
patching file src/http/ngx_http_parse.c
Hunk #2 succeeded at 292 (offset 14 lines).
Hunk #3 succeeded at 518 with fuzz 2 (offset 224 lines).
(Stripping trailing CRs from patch; use --binary to disable.)
patching file src/http/ngx_http_request.c
Hunk #1 succeeded at 1106 (offset -12 lines).
Hunk #2 succeeded at 1783 with fuzz 2 (offset 27 lines).
Hunk #3 succeeded at 2117 with fuzz 1 (offset 42 lines).
(Stripping trailing CRs from patch; use --binary to disable.)
patching file src/http/ngx_http_request.h
Hunk #1 succeeded at 538 with fuzz 2 (offset 127 lines).
(Stripping trailing CRs from patch; use --binary to disable.)
patching file src/http/ngx_http_variables.c
[deployer@host-172-25-4-37 nginx-1.22.0]$ sudo ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/home/deployer/ngx_http_proxy_connect_module
checking for OS
 + Linux 3.10.0-1062.el7.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
und
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
configuring additional modules
adding module in /home/deployer/ngx_http_proxy_connect_module
/home/deployer/ngx_http_proxy_connect_module/config: line 2: $'\r': command not found
/home/deployer/ngx_http_proxy_connect_module/config: line 15: syntax error: unexpected end of file
 was configuredxy_connect_module
checking for PCRE2 library ... not found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile
...
...
Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

[deployer@host-172-25-4-37 nginx-1.22.0]$ sudo make && sudo make install
make -f objs/Makefile
make[1]: 进入目录“/home/deployer/nginx-1.22.0”
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/nginx.o \
        src/core/nginx.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/src/core/ngx_log.o \
...
...
        -o objs/src/stream/ngx_stream_upstream_random_module.o \
        src/stream/ngx_stream_upstream_random_module.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/stream \
        -o objs/src/stream/ngx_stream_upstream_zone_module.o \
        src/stream/ngx_stream_upstream_zone_module.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs -I src/stream \
        -o objs/src/stream/ngx_stream_ssl_preread_module.o \
        src/stream/ngx_stream_ssl_preread_module.c
cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
        -o objs/ngx_modules.o \
        objs/ngx_modules.c
cc -o objs/nginx \
objs/src/core/nginx.o \
objs/src/core/ngx_log.o \
objs/src/core/ngx_palloc.o \
objs/src/core/ngx_array.o \
objs/src/core/ngx_list.o \
objs/src/core/ngx_hash.o \
objs/src/core/ngx_buf.o \
objs/src/core/ngx_queue.o \
...
...
objs/src/stream/ngx_stream_set_module.o \
objs/src/stream/ngx_stream_upstream_hash_module.o \
objs/src/stream/ngx_stream_upstream_least_conn_module.o \
objs/src/stream/ngx_stream_upstream_random_module.o \
objs/src/stream/ngx_stream_upstream_zone_module.o \
objs/src/stream/ngx_stream_ssl_preread_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lpthread -lz \
-Wl,-E
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
        -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \
        -e "s|%%CONF_PATH%%|/usr/local/nginx/conf/nginx.conf|" \
        -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
        < man/nginx.8 > objs/nginx.8
make[1]: 离开目录“/home/deployer/nginx-1.22.0”
make -f objs/Makefile install
make[1]: 进入目录“/home/deployer/nginx-1.22.0”
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
        || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
        || mv '/usr/local/nginx/sbin/nginx' \
                '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
        || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \
        || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \
        || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \
        '/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \
        || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params' \
        || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params \
        '/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params' \
        || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params \
        '/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf' \
        || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
        || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
make[1]: 离开目录“/home/deployer/nginx-1.22.0”
[deployer@host-172-25-4-37 nginx-1.22.0]$ sudo nginx -V
nginx version: nginx/1.22.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/home/deployer/ngx_http_proxy_connect_module
[deployer@host-172-25-4-37 nginx-1.22.0]$ sudo nginx -s reload
nginx: [emerg] unknown directive "proxy_connect" in /usr/local/nginx/conf/nginx.conf:56
[deployer@host-172-25-4-37 nginx-1.22.0]$ sudo nginx -t
nginx: [emerg] unknown directive "proxy_connect" in /usr/local/nginx/conf/nginx.conf:56
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

Activity

Lixxcn

Lixxcn commented on Aug 24, 2022

@Lixxcn
Author

您能帮我看看是哪里的问题吗,nginx配置文件
mmexport1661333727851.png

chobits

chobits commented on Aug 24, 2022

@chobits
Owner

Try to stop nginx (make sure no nginx worker or master process found), then use new binary to start. reload not work for old nginx binary image in ur memory.

确保先把老的nginx关闭,然后再用新的nginx二进制启动。

Lixxcn

Lixxcn commented on Aug 25, 2022

@Lixxcn
Author

Try stop nginx (make sure no nginx worker or master process found), then use new binary to start. reload not work for old nginx binary image in ur memory.

确保先把老的nginx关闭,然后再用新的nginx二进制启动。

终于升级成功了,我有两台机器,一个按照您说的,把老的nginx关闭了进行升级,一个没有关闭也可以升级。作为菜鸟简单总结一下

  1. ngx_http_proxy_connect_module 下打patch和nginx版本有对应关系。
  2. 一定要直接下载ngx_http_proxy_connect_module GitHub仓库里的tar.gz压缩包进行后续处理 ,直接在本地git clone下来在压缩上传到服务器存在Windows编码问题。
  3. 在nginx安装目录下编译有错误,要把整个nginx安装目录删除(因为打补丁会修改源文件),重新解压nginx源文件进行安装一系列操作。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @chobits@Lixxcn

        Issue actions

          nginx: [emerg] unknown directive "proxy_connect" · Issue #236 · chobits/ngx_http_proxy_connect_module