docker 快速部署 nginx 环境,适用于 HTML 页面站点,简单 Web 测试环境以及反向代理 docker 容器等需求.
Go to file
Stille 4df5cbe630 Update to support docker compose 2021-06-18 21:54:27 +08:00
conf Create configuration files 2020-03-27 13:43:08 +08:00
html Create configuration files 2020-03-27 13:43:08 +08:00
ssl Create configuration files 2020-03-27 13:43:08 +08:00
vhost Update to support docker compose 2021-06-18 21:54:27 +08:00
.gitignore Create .gitignore 2020-03-27 13:42:13 +08:00
README.md Update to support docker compose 2021-06-18 21:54:27 +08:00
docker-compose.yml Update to support docker compose 2021-06-18 21:54:27 +08:00

README.md

nginx

docker 快速部署 nginx 环境,适用于 HTML 页面站点,简单 Web 测试环境以及反向代理 docker 容器等需求.

部署

docker

在 root 目录下 git clone 本仓库用来挂载相关配置文件

cd ~
git clone https://github.com/stilleshan/nginx.git

启动 nginx 容器

docker run -d --name=nginx --restart=always \
    --network host \
    -v ~/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
    -v ~/nginx/vhost:/etc/nginx/conf.d/vhost \
    -v ~/nginx/ssl:/etc/nginx/ssl \
    -v ~/nginx/html:/usr/share/nginx/html \
    nginx

docker compose

cd ~
git clone https://github.com/stilleshan/nginx.git
cd nginx
docker-compose up -d

说明

~/nginx/conf 用于存放nginx 主配置文件

conf 目录下为官方 nginx.conf 配置文件,已新增 include vhost 目录以方便挂载多站点配置文件.

~/nginx/vhost 用于存放各站点 conf 配置文件

vhost 目录中已有常用的 conf 样本,参考修改域名和证书路径.

~/nginx/ssl 用于存放证书文件

ssl 目录有样本 conf 所需证书文件,如需删除请连同 conf 样本一起删除,避免 nginx 报错.

~/nginx/html 用于存放网页文件

html 目录为站点根目录,自行创建子目录存放网页以用来部署多个站点.

链接

Docker 打造支持快速部署和迁移的 Nginx 环境