1.下載
wget https://tengine.taobao.org/download/tengine-3.0.0.tar.gz
或者直接下載這個包括下邊兩個配置文件了
https://download.csdn.net/download/cyw8998/89286114
2.編輯nginx.conf文件
#####user nobody;
worker_processes 1;#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#error_log "pipe:rollback logs/error_log interval=1d baknum=7 maxsize=2G";#pid logs/nginx.pid;events {worker_connections 1024;
}http {include mime.types;default_type application/octet-stream;sendfile on;#tcp_nopush on;keepalive_timeout 65;#gzip on;upstream AAA{server 172.16.10.226:50003;server 172.16.10.226:50004;check interval=3000 rise=2 fall=5 timeout=1000 type=http;#check_http_send "HEAD /app/test HTTP/1.0\r\n\r\n";check_http_send "HEAD / HTTP/1.0\r\n\r\n";check_http_expect_alive http_2xx http_3xx;}server {listen 18888;server_name localhost;#charset koi8-r;#access_log logs/host.access.log main;#access_log "pipe:rollback logs/host.access_log interval=1d baknum=7 maxsize=2G" main;location /status {check_status; #stub_status on;access_log off; }location / {proxy_pass http://AAA;#root html;#index index.html index.htm;}}}
注意check_http_send值的設定。由于它的默認值是"GET / HTTP/1.0\r\n\r\n"。假設你的應用是通過http://ip/name訪問的,那么這里你的check_http_send值就需要更改為"GET /name HTTP/1.0\r\n\r\n"才可以。
3.編輯Dockerfile文件
FROM centos:7
#將同級目錄下的文件tengine-3.0.0.tar.gz拷貝到該目錄下
ADD tengine-3.0.0.tar.gz /usr/local/etc/
## 安裝編譯工具,開始安裝編譯tengine
RUN yum install -y gcc gcc-c++ make zlib-devel pcre-devel openssl-devel vim \&& cd /usr/local/etc/tengine-3.0.0 \&& ./configure --add-module=modules/ngx_http_upstream_check_module \&& make \&& make install
# 將Dockerfile同級目錄下的nginx.conf配置文件拷貝到鏡像的該目錄下
ADD nginx.conf /usr/local/nginx/conf/# 向外暴露 80 和 8888 端口
EXPOSE 80 8888 18888# 設置啟動命令
CMD ["/usr/local/nginx/sbin/nginx", "-g", "daemon off;"]
4.制作鏡像
docker build -t tenginetest .
5.運行
docker run -d -p 19999:18888 --name=mytest teginetest