Can someone point me to a guide which describes how to compile nginx dynamic modules?

Tried to give it a go myself and ended up with an error saying it didn't recognize some upstream symbol, and my head hurts from staying up so late, and I'm rambling, and any help would be most appreciated, bitte und danke.

P.S. I'm not looking for advice concerning how to compile in general. I know how to compile things. I'm looking for specific steps with regard to compiling things for nginx.

Comments (2)

Sébastien Portebois's photo

Hi

I'm not sure what your current issue is, what is the missing module, what are the errors, so please forgive me if this post doesn't exactly address your issue.

Here's an excerpt from a Dockerfile of a custom Alpine+NGINX image in which I compile NGINX to have specific settings and modules (this is from a private repo, hence the excerpt without source link). Hopefully this could give you hints at missing arguments you might need:

I remove some unrelated commands here (In the real file I also have S6 overlay and gunicorn), I tried to clean this snippet, but I might have left some unneeded dependencies or build-dependencies (in other words, in might not be perfect since it's been customized here and not tested). If something looks strange to you, please let me know, I'll check if I did a copy/clean mistake or if there a good reason for that.

# Build Nginx from source
RUN apk update && apk upgrade && \
    apk add --no-cache curl wget bash && \
    echo "Build Nginx from source" && \
    apk add --no-cache openssl-dev pcre-dev zlib-dev && \
    apk add --no-cache --virtual .build-deps libffi-dev build-base musl-dev linux-headers make gcc g++ && \
    curl -Ls http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz | tar -xz -C /tmp && \
    cd /tmp/nginx-${NGINX_VERSION} && \
    ./configure \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --prefix=${NGINX_HOME} \
        --conf-path=/etc/nginx/nginx.conf \
        --http-log-path=/var/log/nginx/access.log \
        --error-log-path=/var/log/nginx/error.log \
        --pid-path=/var/run/nginx.pid \
        --sbin-path=/usr/sbin/nginx && \
    make && \
    make install && \
    echo -ne "- with `nginx -v 2>&1`\n" >> /root/.built && \
    echo "Forward request and error logs to docker log collector" && \
    ln -sf /dev/stdout /var/log/nginx/access.log  && \
    ln -sf /dev/stderr /var/log/nginx/error.log && \
    echo "Prepare LetsEncrypt folders" && \
    mkdir -p /etc/letsencrypt && \
    mkdir -p /var/www/letsencrypt && \
    echo "Clean build stuff" && \
    rm -rf /tmp/* && \
    apk del .build-deps

Hope this helps.

J03's photo

Thank you for the assistance. This looks like something that could be useful to me finding my way with respect to custom compiling NGINX.

I think my frustration primarily lied in trying to jump in and compile nginx dynamic modules for the first time at 3am, expecting everything to be all hunky dory on the first try. I feel like I'll have more success the next time I head into that cave, so long as I don't attempt to do so on a lack of sleep.