nginx: [emerg] unknown directive "proxy_connect" in
0. Before Your ASK
- Try to find an answer by reading a FAQ.
Ⅰ. Issue Description
Ⅱ. Describe what happened
Ⅲ. Describe what you expected to happen
Ⅳ. How to reproduce it (as minimally and precisely as possible)
1. 2. 3.
Ⅴ. Anything else we need to know?
- If applicable, add nginx debug log. 2. 3.
Ⅵ. Environment:
- Tengine/Nginx/OpenResty version (use
sbin/nginx -v): - Which patch do you use?
./nginx -t
unknown directive "proxy_connect" means that this module is not built into ur nginx binary.
Please check whether this module is installed! See install-man-page.
I am using nginx 1.16.1, meet the same problem, unknown directive "proxy_connect" i have installed this module guiding by the install-man-page.
./nginx -t
have you resolved the problem?
HI man,
I cant resolve your problem with the information you provided.
For the error of unknown directive "proxy_connect" , some reasons I can think of are:
- the proxy_connect module may be not compiled with your nginx.
./nginxmay be not the compiled new nginx binary. Use./nignx -Vto check whether proxy_connect module is in your configuration command.
I compiled nginx with this module as following, and it can work,
$ ls
nginx-1.18.0 ngx_http_proxy_connect_module pcre-8.00
$ cd nginx-1.18.0/
$ patch -p1 < ../ngx_http_proxy_connect_module/patch/proxy_connect_rewrite_1018.patch
$ cat genmake.sh
./configure --with-pcre=../pcre-8.00 --add-module=../ngx_http_proxy_connect_module \
--prefix=$(pwd)/output \
--with-debug
$ sh genmake.sh
...too many messages ...
$ make -j4
...too many messages ...
$ objs/nginx -V
nginx version: nginx/1.18.0
built by clang 11.0.0 (clang-1100.0.33.12)
configure arguments: --with-pcre=../pcre-8.00 --add-module=../ngx_http_proxy_connect_module --prefix=/Users/xiaochen/work/github/nginx-1.18.0/output --with-debug
Hey @chobits , I am using this[https://gist.github.com/DawidJanczak/2f7201ea427d2edbc1fa3349b7f70f1c ] docker file with --add-dynamic-module. It generates the module successfully. Simply when I run a new image copy the generated proxy module, still get the error as unknown directive "proxy_connect" Here is my docker file. Do you see what is wrong here? Though I see the proxy module is present inside image.
FROM nginx:1.18.0-alpine AS builder
RUN wget http://nginx.org/download/nginx-1.18.0.tar.gz -O nginx.tar.gz && \
wget https://api.github.com/repos/chobits/ngx_http_proxy_connect_module/tarball/2bf28ad10e6cf372dab412a6b5f565f7f4e31e73 -O connect.tar.gz
RUN apk add --no-cache --virtual .build-deps \
gcc \
libc-dev \
make \
openssl-dev \
pcre-dev \
zlib-dev \
linux-headers \
curl \
gnupg \
libxslt-dev \
gd-dev \
geoip-dev
RUN pwd
RUN CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p') \
tar -xzvf nginx.tar.gz && \
tar -xzvf connect.tar.gz && \
cd nginx-1.18.0 && \
patch -p1 < /chobits-ngx_http_proxy_connect_module-2bf28ad/patch/proxy_connect_rewrite_1018.patch && \
./configure $CONFARGS --with-http_ssl_module \
--with-http_stub_status_module \
--with-http_realip_module \
--with-threads \
--add-dynamic-module=/chobits-ngx_http_proxy_connect_module-2bf28ad && \
make && \
make install
# Production container starts here
FROM nginx:1.18.0-alpine
COPY --from=builder /usr/local/nginx/modules/ngx_http_proxy_connect_module.so /etc/nginx/modules/ngx_http_proxy_connect_module.so
COPY entrypoint.sh /nginx-entrypoint.sh
ENTRYPOINT ["/nginx-entrypoint.sh"]
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"]
I was missing the load_module /usr/lib/nginx/modules/ngx_http_proxy_connect_module.so; in the conf file. But later when i added it give error as
module "/usr/lib/nginx/modules/ngx_http_proxy_connect_module.so" is not binary compatible in /etc/nginx/nginx.conf:2
module "/usr/lib/nginx/modules/ngx_http_proxy_connect_module.so" is not binary compatible in /etc/nginx/nginx.conf:2
This error means the nginx binary you used is not the one that was compiled with ngx_http_proxy_connect.so.
When compiling ngx_http_proxy_connect_module.so, you will get one nginx binary also. You should use this nginx binary to start and load ngx_http_proxy_connect_module.so.
Thanks @chobits . I compiled the ngx_http_proxy_connect_module.so using the nginx:1.18.0-alpine image, same I used in building the main image, below is the snippet, then why still there is a compatible issue. I don't understand how to use the binary which is generated while building the ngx_http_proxy_connect_module in the main Image. Please give example if you have.
Refer: https://github.com/chobits/ngx_http_proxy_connect_module/issues/157#issuecomment-663809346
FROM nginx:1.18.0-alpine
COPY --from=builder /usr/local/nginx/modules/ngx_http_proxy_connect_module.so /usr/lib/nginx/modules/ngx_http_proxy_connect_module.so
COPY entrypoint.sh /nginx-entrypoint.sh
ENTRYPOINT ["/nginx-entrypoint.sh"]
EXPOSE 80
STOPSIGNAL SIGTERM
CMD ["nginx", "-g", "daemon off;"]
I don't understand how to use the binary which is generated while building the ngx_http_proxy_connect_module in the main Image.
That means you should use generated nginx to start. This nginx binary is here: /path/to/nginx-source/objs/nginx. You should copy this binary to replace original nginx binary

Find nginx binary from nginx-1.18.0/objs/nginx, nginx-1.18.0/ is directory where you compile nginx