gpt4 book ai didi

mysql - 将 SSL 证书添加到 mysql docker 容器

转载 作者:IT老高 更新时间:2023-10-28 21:26:49 25 4
gpt4 key购买 nike

我正在为一个使用 nginx 和 uwsgi 的 django 应用程序构建一个 docker 容器。对于数据库,应用程序正在使用 mysql,它位于不同的容器中,并且它们都与 docker-compose.yml 文件链接:

version: '2'
services:
mysql:
image: mysql:latest
environment:
-MYSQL_DATABASE: TheDatabase
-MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
-MYSQL_USER: TheUsername
-MYSQL_PASSWORD: ThePassword

ports:
-"3306:3306"

django:
build: .
volumes:
- .:/app
ports:
- "443:443"
- "8000:8000"
links:
- mysql

我正在使用 SSL 证书,这些证书使用 OpenSSL 自签名并包含在 nginx.conf 文件中。问题是每次我运行容器并尝试以 super 用户身份登录时,都会收到以下错误 504 Timed Out。经过大量思考后,我得出结论,问题出在与 mysql 数据库的连接上。我确实进入了 mysql 容器并看到数据库在那里,在检查表之后,我看到所有表都已创建。但是,在阅读日志后,我注意到以下行:

[Warning] Failed to set up SSL because of the following SSL library error: SSL context is not usable without certificate and private key.

当我使用来自 docker hub 的现成镜像时,我应该如何添加 SSL key 和证书?这就是我收到 504 Timed out 错误的原因吗?我还收到以下 3 个警告:

[Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.

[Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.

[Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode

最佳答案

"If you want the server to be able to deploy with automatic support for secure connections, use the mysql_ssl_rsa_setup utility to create default SSL and RSA files:

shell> mysql_ssl_rsa_setup

For more information, see Section 4.4.5, “mysql_ssl_rsa_setup — Create SSL/RSA Files”.

mysql_ssl_rsa_setup

只有 MySQL 企业版服务器会在 --initialize 时间为您创建证书。

Courtesy-MySQL

关于mysql - 将 SSL 证书添加到 mysql docker 容器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40997758/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com