1、环境
- 操作系统:Centos 7
- docker 版本:19.03.7
- docker-compose 版本:1.24.0
- 容器中Nginx 版本:1.17.9
2、目录结构
$ tree -L 2
.
├── conf.d
│ └── webui.conf
├── docker-compose.yml
├── Dockerfile
└── static
├── 50x.html
├── index.html
...
其中,conf.d目录放置Nginx反向代理的配置文件,static中为web的静态资源文件。
3、各个配置文件定义如下:
3.1 webui.conf
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
#虚拟主机配置
server {
listen 80; #侦听80端口,并为默认服务, default_server只能有一个
server_name localhost; #服务域名,可以有多个, 用空格隔开
charset utf-8;
location / {
root /usr/share/nginx/html; #定义服务器的默认网站根目录位置
autoindex on;
access_log on;
index index.html index.htm; #定义index页面
}
location /api/v1

本文档详细介绍了如何在Centos 7环境下,利用docker-compose部署Nginx反向代理服务。首先介绍了操作系统的版本、docker及docker-compose的版本,接着展示了配置文件webui.conf、Dockerfile和docker-compose.yml的内容。然后,说明了如何构建镜像并启动Nginx服务,以及检查镜像和服务是否成功启动。最后,提到了通过浏览器访问的效果,并提供了相关参考资料。
最低0.47元/天 解锁文章
618





