docker-compose安装nginx并配置
1、docker-compose配置文件
version: "3.2"
services:
ngnix:
container_name: nginx-zhxmgl
image: nginx
restart: always
ports:
- 8000:80
- 8081:81
- 8083:83
privileged: true
volumes:
- /home/docker/zhxmgl2/nginx/conf:/etc/nginx
- /home/docker/zhxmgl2/nginx/logs:/var/log/nginx
- /home/docker/zhxmgl2/nginx/html:/usr/share/nginx/html
- /etc/letsencrypt:/etc/letsencrypt
- /etc/localtime:/etc/localtime
2、nginx配置文件修改
#配置1
server {
listen 81;
server_name localhost;
location /charge/files/ {
proxy_pass http://192.168.204.201:82/;
}
location / {
root /usr/share/nginx/html/web1;
index index.html index.htm;
}
}
#配置2
server {
listen 83;
server_name localhost;
location / {
root /usr/share/nginx/html/web2;
index index.html index.htm;
}
}
![在这里插入图片描述](https://img-blog
.csdnimg.cn/d7d46e10f1c14733b7b66da9e6b15012.png)
3、启动及停止命令
进入到docker-compose目录。
执行:docker-compose up -d --build,启动
执行:docker-compose down,停止
[root@localhost zhxmgl2]# pwd
/home/docker/zhxmgl2
[root@localhost zhxmgl2]# ls
docker-compose.yml gateway nginx oauth2-auth system xmgl
[root@localhost zhxmgl2]# docker-compose up -d --build