The Wayback Machine - https://web.archive.org/web/20201108014305/https://github.com/EsWork/docker-nginx
Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Build Status

Image Tag Metadata from image

Supported tags and respective Dockerfile links

  • eswork/nginx 参考Features
  • eswork/nginx:lt 轻量化模块

Features

Notes

  • nginx默认端口为8000/4430,而不是80/443,如果自定义nginx.conf配置的端口请不要使用1024以下的端口(使用root的UID/GID不限制)

Volumes

  • /etc/nginx/sites-enabled : vhosts文件 (*.conf)
  • /etc/nginx/conf.d : 额外的配置文件 (*.conf)
  • /etc/nginx/certs : SSL/TLS certificates
  • /var/log/nginx : nginx logs
  • /var/www : 站点目录

Build-time variables

Dockerfile文件的ARG参数可控制开启/关闭相应功能

ARG WITH_DEBUG=false
ARG WITH_NDK=true
ARG WITH_LUA=true
ARG WITH_PURGE=true
ARG WITH_UPSTREAM_CHECK=true

Environment variables

  • GID : nginx group id (default : 1000)
  • UID : nginx user id (default : 1000)

Installation

自动化构建镜像的可用Dockerhub和推荐的安装方法

docker pull eswork/nginx

或者你可以自己构建镜像

docker build -t eswork/nginx github.com/eswork/docker-nginx

Quickstart

运行nginx:

docker run --name nginx -d \
  -p 8000:8000 --restart=always \
  eswork/nginx 

或者您可以使用示例docker-compose.yml文件启动容器

Configuration

自定义您的配置文件覆盖容器默认的/etc/nginx/nginx.conf配置

docker run --name nginx -d \
-p 8000:8000 -v /some/nginx.conf:/etc/nginx/nginx.conf:ro \
eswork/nginx

挂载您自己的sites-enabled目录到/etx/nginx/sites-enabled

docker run --name nginx  -d \
-p 8000:8000 \
-v /some/nginx.conf:/etc/nginx/nginx.conf:ro \
-v /srv/docker/nginx/sites-enabled:/etc/nginx/sites-enabled \
eswork/nginx

重新加载的NGINX配置使用kill -s HUP发送到容器上

docker kill -s HUP nginx

Logs

访问Nginx日志位于/var/log/nginx

docker exec -it nginx tail -f /var/log/nginx/access.log

Test

执行以下命令启动容器

docker run -p 8000:8000 --name nginx -d \
eswork/nginx nginx -c /etc/nginx/test.conf 

测试地址

先访问http://localhost:8000/index.html ,然后再次访问http://localhost:8000/purge/index.html会看到效果

其实访问http://localhost:8000/index.html地址已经使用反向代理到http://localhost:8045/index.html页面上

访问http://localhost:8000/lua页面将会显示hello lua.

访问http://localhost:8000/status1页面将会显示stub状态

访问http://localhost:8000/status2页面将会显示upstream状态

You can’t perform that action at this time.