连接到 AWS RDS 实例时,带有 Docker 的 phpMyAdmin 不使用 SSL

发布于 2025-01-11 10:36:51 字数 1565 浏览 0 评论 0原文

我正在使用 phpMyAdmin docker 映像连接到 AWS RDS 实例并需要它使用 SSL。一切均按照 PMA 文档< /a> 但它不会使用 SSL。

创建容器时,config.user.inc.php 和 rds-combined-ca-bundle.pem 都会被复制到 /etc/phpmyadmin 目录。

登录数据库服务器时,PMA 显示服务器连接:SSL 未使用。 当 RDS 中的数据库用户设置为 SSL 时,需要登录失败,而当设置为不需要 SSL 时,我可以正常登录。希望有人能帮助我解决这个问题。

Docker 组合

version: '3.1'

services:
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    environment:
      PMA_HOST: somerdsserver.us-east-1.rds.amazonaws.com
      PMA_PORT: 3306
    restart: always
    ports:
      - 8081:80
    volumes:
      - /sessions
      - /home/centos/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
      - /home/centos/phpmyadmin/rds-combined-ca-bundle.pem:/etc/phpmyadmin/rds-combined-ca-bundle.pem

配置.user.inc.php

<?php

// Address of your instance
$cfg['Servers'][$i]['host'] = 'somerdsserver.us-east-1.rds.amazonaws.com';
// Use SSL for connection
$cfg['Servers'][$i]['ssl'] = true;
// Enable SSL verification
$cfg['Servers'][$i]['ssl_verify'] = true;
// You need to have the region CA file and the authority CA file (2019 edition CA for example) in the PEM bundle for it to work
$cfg['Servers'][$i]['ssl_ca'] = '/etc/phpmyadmin/rds-combined-ca-bundle.pem';

I am using phpMyAdmin docker image to connect to a AWS RDS instance and need it to use SSL. Everything is set as directed by PMA documentation but it will not use SSL.

Both config.user.inc.php and rds-combined-ca-bundle.pem are being copied to /etc/phpmyadmin directory when container is created.

When logging into DB server, PMA shows Server connection: SSL is not being used.
When database user in RDS is set to SSL required login fails and when set to not require SSL I am able to login OK. Hopefully someone can help me out with this.

Docker Compose

version: '3.1'

services:
  phpmyadmin:
    image: phpmyadmin/phpmyadmin
    container_name: phpmyadmin
    environment:
      PMA_HOST: somerdsserver.us-east-1.rds.amazonaws.com
      PMA_PORT: 3306
    restart: always
    ports:
      - 8081:80
    volumes:
      - /sessions
      - /home/centos/phpmyadmin/config.user.inc.php:/etc/phpmyadmin/config.user.inc.php
      - /home/centos/phpmyadmin/rds-combined-ca-bundle.pem:/etc/phpmyadmin/rds-combined-ca-bundle.pem

config.user.inc.php

<?php

// Address of your instance
$cfg['Servers'][$i]['host'] = 'somerdsserver.us-east-1.rds.amazonaws.com';
// Use SSL for connection
$cfg['Servers'][$i]['ssl'] = true;
// Enable SSL verification
$cfg['Servers'][$i]['ssl_verify'] = true;
// You need to have the region CA file and the authority CA file (2019 edition CA for example) in the PEM bundle for it to work
$cfg['Servers'][$i]['ssl_ca'] = '/etc/phpmyadmin/rds-combined-ca-bundle.pem';

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

贱贱哒 2025-01-18 10:36:51

您可以在 docker-compose 中创建一个卷,并将 apache 配置和证书复制到容器

  phpmyadmin:
    container_name: phpmyadmin
    hostname: phpadmin.domain
    image: phpmyadmin:latest
    restart: always
    build:
      context: .
      dockerfile: phpmyadmin.dockerfile
    ports:
      - 8080:443
    volumes:
      - ./phpmyadmin/000-default.conf:/etc/apache2/sites-enabled/000-default.conf
      - ./ssl/cert.pem:/etc/ssl/cert.pem
      - ./ssl/cert.key:/etc/ssl/cert.key

phpmyadmin/000-default.conf:

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    
    SSLEngine on
    
    SSLCertificateFile    /etc/ssl/cert.pem
    SSLCertificateKeyFile /etc/ssl/cert.key
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

要完成,您需要使用 a2enmod 启用 ssl 并重新启动 apache,在我的情况下,我使用 phpmyadmin.dockerfile :

FROM phpmyadmin
RUN a2enmod ssl

就是这样。

You can create a volume in docker-compose and replicate apache config and certificates to container

  phpmyadmin:
    container_name: phpmyadmin
    hostname: phpadmin.domain
    image: phpmyadmin:latest
    restart: always
    build:
      context: .
      dockerfile: phpmyadmin.dockerfile
    ports:
      - 8080:443
    volumes:
      - ./phpmyadmin/000-default.conf:/etc/apache2/sites-enabled/000-default.conf
      - ./ssl/cert.pem:/etc/ssl/cert.pem
      - ./ssl/cert.key:/etc/ssl/cert.key

phpmyadmin/000-default.conf:

<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
    
    SSLEngine on
    
    SSLCertificateFile    /etc/ssl/cert.pem
    SSLCertificateKeyFile /etc/ssl/cert.key
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

To finish you need enable ssl with a2enmod and restart apache, in my case I am using phpmyadmin.dockerfile with:

FROM phpmyadmin
RUN a2enmod ssl

That's it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文