ubuntunginxdockerphusion

How could I run nginx-naxsi in baseimage?


I had try baseimage 0.9.19 (Ubuntu 16.04) & 0.9.18 (Ubuntu 14.04).

0.9.18 got:

apt-get purge nginx-*
apt-get install nginx-naxsi

The following packages have unmet dependencies:
nginx-naxsi : Depends: nginx-common (= 1:1.6.3-8.5.0.7~trusty1) but 1:1.10.1-8.5.0.30~trusty1 is to be installed
E: Unable to correct problems, you have held broken packages.

0.9.19 got:

no package: nginx-naxsi

And the compiling seems not work in baseimage:
https://github.com/nbs-system/naxsi/wiki/naxsi-compil


Solution

  • I got the answer from Github:
    https://github.com/phusion/baseimage-docker/issues/344#issuecomment-254717556

    Here is the Dockerfile @notpeter gave to me:

    ########################################################
    # Nginx + naxsi docker baseimage (ubuntu xenial 16.06) #
    ########################################################
    
    FROM phusion/baseimage:0.9.19
    MAINTAINER Peter Tripp "peter.tripp@gmail.com"
    
    ENV NGINX_VERSION 1.10.2
    ENV NAXSI_VERSION 0.55.1
    
    CMD ["/sbin/my_init"]
    
    RUN apt-get update && \
        apt-get install -y tar git vim nano wget net-tools build-essential \
            libpcre3-dev libxslt1-dev libgd2-xpm-dev libgeoip-dev libssl-dev
    
    RUN cd /tmp/ && \
        wget https://github.com/nbs-system/naxsi/archive/$NAXSI_VERSION.tar.gz && \
        wget https://nginx.org/download/nginx-$NGINX_VERSION.tar.gz && \
        tar xf $NAXSI_VERSION.tar.gz && \
        tar xf nginx-$NGINX_VERSION.tar.gz && \
        cd nginx-$NGINX_VERSION && \
        ./configure --conf-path=/etc/nginx/nginx.conf \
            --add-module=../naxsi-$NAXSI_VERSION/naxsi_src \
            --error-log-path=/var/log/nginx/error.log \
            --http-client-body-temp-path=/var/lib/nginx/body \
            --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
            --http-log-path=/var/log/nginx/access.log \
            --http-proxy-temp-path=/var/lib/nginx/proxy \
            --lock-path=/var/lock/nginx.lock \
            --pid-path=/var/run/nginx.pid \
            --with-http_ssl_module \
            --without-mail_pop3_module \
            --without-mail_smtp_module \
            --without-mail_imap_module \
            --without-http_uwsgi_module \
            --without-http_scgi_module \
            --with-ipv6 \
            --prefix=/usr && \
        make && \
        make install && \
        mkdir -p /var/lib/nginx/{body,proxy}
    
    RUN echo "daemon off;" >> /etc/nginx/nginx.conf && \
        mkdir -p /etc/service/nginx && \
        echo "#!/usr/bin/env bash\n\nnginx" > /etc/service/nginx/run && \
        chmod +x /etc/service/nginx/run
    
    # Cleanup.
    RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*