目录
docker-compose文件信息
nginx文件信息
证书生成
查看文件有哪些!!!
在 .yml 文件目录运行
查看容器情况并访问网页
当然,以下是一个使用 MySQL 5.7、Nginx 和 ownCloud 的完整 Docker Compose 示例,同时启用 SSL/TLS 以确保安全的数据传输
docker-compose文件信息
version: '3'
services:
dbs:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: Root12345.
MYSQL_DATABASE: owncloud
MYSQL_USER: owncloud
MYSQL_PASSWORD: owncloud
owncloud:
image: owncloud:latest
ports:
- 8080:8080
depends_on:
- dbs
environment:
- OWNCLOUD_DB_TYPE=mysql
- OWNCLOUD_DB_NAME=owncloud
- OWNCLOUD_DB_USERNAME=owncloud
- OWNCLOUD_DB_PASSWORD=owncloud
- OWNCLOUD_DB_HOST=dbs
volumes:
- owncloud_data:/var/www/html
restart: always
nginx:
image: nginx:latest
ports:
- 80:80
- 443:443
depends_on:
- owncloud
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
- ./certs:/etc/nginx/certs/
restart: always
volumes:
db_data:
owncloud_data:
nginx文件信息
worker_processes 1;
events { worker_connections 1024; }
http {
server {
listen 80;
server_name DockerI.com;
location / {
proxy_pass http://DockerI.com:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 443 ssl;
server_name DockerI.com;
ssl_certificate /etc/nginx/certs/DockerI.com.crt;
ssl_certificate_key /etc/nginx/certs/DockerI.com.key;
location / {
proxy_pass http://DockerI.com:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
}
证书生成
yum install openssl
#创建自签名SSL证书私钥
openssl genrsa -out DockerI.com.key 4096
#使用私钥生成自签名SSL证书请求文件
openssl req -new -key DockerI.com.key -out DockerI.com.csr
#使用私钥和CSR文件生成自签名SSL证书
openssl x509 -req -in DockerI.com.csr -signkey DockerI.com.key -out DockerI.com.crt
查看文件有哪些!!!
在 .yml 文件目录运行
查看容器情况并访问网页
就OK啦!!!