docker-compose部署nginx
一.nginx.conf在/etc/nginx目录下配置nginx.conf文件,如果没有,直接touch生成http {server {listen80 default_server;listen[::]:80 default_server;server_name_;...
·
一.nginx.conf
在/etc/nginx目录下配置nginx.conf文件,如果没有,直接touch生成
http {
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
client_max_body_size 20M;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /opt/dist-generator/;
index index.html;
}
location /generator/ {
proxy_pass http://192.168.5.21:8085; //8085指的是应用的端口
}
}
}
二.docker-compose.yml
在docker-compose.yml部署nginx镜像时注意挂载的目录
nginx:
container_name: nginx
image: nginx
restart: unless-stopped
ports:
- 8080:80 //这个80指的是nginx.conf监控的80端口,8080指外部访问的8080
volumes:
- /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- /opt/dist:/opt/dist
- /opt/dist-generator:/opt/dist-generator //挂载目录要与conf配置的一致
environment:
- TZ=Asia/Shanghai
networks:
default:
external:
name: bridge
三.启动docker-compose
在docker-compose.yml目录启动: docker-compose up -d
四.访问8080端口查看
更多推荐
已为社区贡献10条内容
所有评论(0)