我怎么能在baseimage中运行nginx-naxsi?

时间:2016-10-17 04:18:16

标签: ubuntu nginx docker phusion

我尝试过baseimage 0.9.19(Ubuntu 16.04)& 0.9.18(Ubuntu 14.04)。

0.9.18得到了:

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得到了:

no package: nginx-naxsi

编译似乎不适用于baseimage:
https://github.com/nbs-system/naxsi/wiki/naxsi-compil

1 个答案:

答案 0 :(得分:0)

我从Github那里得到了答案:
https://github.com/phusion/baseimage-docker/issues/344#issuecomment-254717556

这是Dockerfile @notpeter给我的:

########################################################
# 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/*