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

标签 mysql django ssl nginx docker

我正在为一个使用 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/

相关文章:

php - 如何在 php 中删除具有复合(多列)主键的记录

php - move_uploaded_file 在 sql server 上不起作用

python - Django,将 HTML 代码存储在数据库中

amazon-web-services - AWS S3 图像仅通过 HTTP 提供服务,但 Chrome 升级到 HTTPS

c# - 从存储过程返回值并在 C# 中使用它

php - 这个查询迭代是否可能

javascript - 为什么 Django 中的 Google-Auth(Google Identity) 空白弹出窗口?

python - 获取某个字段是否为NULL

c - 将 CURL 使用的普通套接字转换为 C 中的 SSL 套接字

php - 使用 Artax 绕过 SSL 证书验证