Skip to content

Usage with kubernetes/ingress-nginxΒ #1

@zaslavskii

Description

@zaslavskii

Hi!
I'm trying to compile custom dynamic module and use it with ingress-controller 0.44.0 (https://github.com/kubernetes/ingress-nginx/). I made a fork to slightly modify config file to compile it as a dynamic module. https://github.com/chainstack/ngx_http_websocket_stat_module

The resulting dynamic module works fine with pure nginx 1.19.6. But the problem is that when I'm trying to use with ingress-nginx image, it does nothing. No frames are logged and no errors appear:(

I know that it's not a problem of the module itself, but maybe you guys can advise me smth to look at.

This is the dockerfile I came up with to build an nginx with the dynamic module inside.

FROM k8s.gcr.io/ingress-nginx/controller:v0.44.0 as builder
USER root
WORKDIR /tmp
RUN apk add git openssl-dev pcre-dev zlib-dev libc-dev gcc make
RUN NGINX_VERSION=$(nginx -v 2>&1 | sed 's/nginx version: nginx\///') && \
    wget -qO- https://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar xvz && \
    mv nginx-${NGINX_VERSION} nginx
RUN git clone --depth 1 --branch v1.0.0 https://github.com/chainstack/ngx_http_websocket_stat_module.git && \
    cd ./nginx && \
    ./configure  --with-compat --add-dynamic-module=../ngx_http_websocket_stat_module && make modules
FROM k8s.gcr.io/ingress-nginx/controller:v0.44.0
COPY --from=builder /tmp/nginx/objs/ngx_http_websocket_stat_module.so /etc/nginx/modules

The way I was testing it is the following:

  1. I ran docker container from the image
  2. Added load_module /etc/nginx/modules/ngx_http_websocket_stat_module.so; to /etc/nginx/nginx.conf file
  3. Added an nginx service and location sections that accept websocket and proxies it to a dummy websocket backend.
  4. Finally added ws_log* directives to the added service.

P.S.
Maybe you guys know some other way that allows to log each time frame goes through websocket connection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions