openresty / headers-more-nginx-module

Set, add, and clear arbitrary output headers in NGINX http servers
1.66k stars 223 forks source link

"/etc/nginx/modules/ngx_http_headers_more_filter_module.so" is not binary compatible #130

Open adimaryadi opened 2 years ago

adimaryadi commented 2 years ago

Anyone know why it's not compatible? I use nginx version: nginx/1.17.8

dvershinin commented 2 years ago

@adimaryadi because you have to compile with a matching version and with --with-compat configure flag.

denosaurtrain commented 2 years ago

@dvershinin I came across this "not binary compatible" error while using Nginx 1.22. I suspect the compiler flags used for the Alpine distribution differ from the flags that the Nginx team uses for the official docker image. The nginx:stable-alpine Docker image, which is based on Nginx 1.22.0-r1 and almost matches the 1.22.0-r2 version shown in the nginx-mod-http-headers-more Alpine package. Here's a minimal reproducible example:

FROM docker.io/nginx:stable-alpine
RUN apk add --no-cache \
    nginx-mod-http-headers-more
RUN echo "load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so;" > /etc/nginx/nginx.conf

Error message:

nginx: [emerg] module "/usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so" is not binary compatible in /etc/nginx/nginx.conf

I can work around the issue by using the nginx Alpine package, which is built by the same person who maintains the Alpine package for this repo.

FROM alpine:3.16
RUN apk add --no-cache \
    nginx \
    nginx-mod-http-headers-more
RUN echo "load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so;" > /etc/nginx/nginx.conf
ENTRYPOINT [ "nginx" ]

I'm not sure if OP's issue is the same as mine because he didn't mention Alpine and is using nginx 1.17.8.

glaszig commented 2 years ago

@adimaryadi i bet the output of your nginx -V is missing --with-compat. you'll need an nginx binary that was compiled with that flag.

vchernov-avenga commented 7 months ago

You need to compile third party modules on your own for official Nginx Docker images https://github.com/nginxinc/docker-nginx/issues/364#issuecomment-752089099