2016-10-17 25 views
0

我曾嘗試baseimage 0.9.19(Ubuntu 16.04)& 0.9.18(Ubuntu 14.04)。如何在baseimage中運行nginx-naxsi?

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

回答

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 "[email protected]" 

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