diff --git a/Dockerfile b/Dockerfile index 3e0361d..f4424ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM centos as builder -ADD http://mirrors.aliyun.com/repo/Centos-7.repo /etc/yum.repos.d/CentOS-Base.repo RUN yum install gcc make pcre-devel zlib-devel openssl-devel -y \ && yum clean all @@ -21,8 +20,8 @@ WORKDIR ${NGX_SRC_DIR} ADD . nginx-http-accounting-module RUN ./configure --prefix=${PREFIX} \ --with-stream \ - --add-module=nginx-http-accounting-module \ - --add-module=echo-nginx-module-master \ + --add-dynamic-module=nginx-http-accounting-module \ + --add-dynamic-module=echo-nginx-module-master \ --http-log-path=/dev/stdout \ --error-log-path=/dev/stderr \ && make -s && make -s install @@ -42,8 +41,9 @@ RUN ln -sf /dev/stdout ${PREFIX}/logs/access.log \ && ln -sf /dev/stderr ${PREFIX}/logs/error.log \ && ln -sf ../usr/share/zoneinfo/Asia/Shanghai /etc/localtime -ADD misc/nginx.conf ${PREFIX}/conf/nginx.conf +ADD samples/nginx.conf ${PREFIX}/conf/nginx.conf -EXPOSE 80 +EXPOSE 8080 +EXPOSE 8888 STOPSIGNAL SIGTERM ENTRYPOINT ["./sbin/nginx", "-g", "daemon off;"] diff --git a/misc/nginx.conf b/samples/nginx.conf similarity index 61% rename from misc/nginx.conf rename to samples/nginx.conf index 925068b..2a24648 100644 --- a/misc/nginx.conf +++ b/samples/nginx.conf @@ -1,3 +1,6 @@ +load_module modules/ngx_http_accounting_module.so; +load_module modules/ngx_http_echo_module.so; + worker_processes auto; error_log logs/error.log notice; @@ -9,12 +12,8 @@ http { include mime.types; default_type application/octet-stream; - #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - # '$status $body_bytes_sent "$http_referer" ' - # '"$http_user_agent" "$http_x_forwarded_for"'; - - #access_log logs/access.log main; access_log off; + log_not_found off; sendfile on; #tcp_nopush on; @@ -25,16 +24,15 @@ http { #gzip on; http_accounting on; - http_accounting_interval 10; + http_accounting_interval 60; http_accounting_perturb on; - http_accounting_id '_NGXTA_'; + http_accounting_id 'HTTP'; http_accounting_log logs/http-accounting.log; - log_not_found off; - server { - listen 1234; + listen 8888; server_name echo; + http_accounting_id $host; location / { echo hello; @@ -49,20 +47,36 @@ http { echo nginx; echo_flush; - http_accounting_id '_HTTP_ECHO_'; + http_accounting_id 'HTTP_ECHO'; + } + + location /echo/now { + echo "Hello world!"; } } server { - listen 80; + listen 8080; server_name localhost; #charset koi8-r; location / { - root html; + return 200 ''; + http_accounting_id $uri; + } + + location /index { + alias html; index index.html index.htm; - http_accounting_id $host; + http_accounting_id "INDEX"; + } + + location /echo { + proxy_pass http://localhost:8888; + proxy_set_header Host "echo"; + proxy_buffering off; + http_accounting_id "HTTP_PROXY_ECHO"; } #error_page 404 /404.html;