使用 docker-compose 部署 mongo-express with cert (https)
Deploy mongo-express with cert (https) with docker-compose
是否可以选择使用域 CERT(使用 HTTPS)和 docker 组合来部署 mongo-express
服务?我有一个带有 CERT 的现有网站(它使用 HTTPS),我想将 mongo-express
集成到它。所以我想将其部署为 https://my_host:8081
.
我当前的测试 docker-compose.yml
文件运行完美,但它使用 HTTP 协议 (http://localhost:8081
)。
我当前的测试docker-compose.yml
文件:
version: "3.8"
services:
db:
container_name: mongo-dev
hostname: mongo-dev
image: mongo:4.2
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_DATABASE=auth
- MONGO_INITDB_ROOT_PASSWORD=pass
networks:
- mongo-compose-network
ports:
- '27017:27017'
volumes:
- ./data:/data/db
mongo-express:
container_name: mongo-express
image: mongo-express:0.54.0
depends_on:
- db
networks:
- mongo-compose-network
environment:
- ME_CONFIG_MONGODB_SERVER=mongo-dev
- ME_CONFIG_MONGODB_ADMINUSERNAME=admin
- ME_CONFIG_MONGODB_ADMINPASSWORD=pass
- ME_CONFIG_BASICAUTH_USERNAME=admin
- ME_CONFIG_BASICAUTH_PASSWORD=tribes
ports:
- '8081:8081'
restart: on-failure
networks:
mongo-compose-network:
driver: bridge
我知道可以用 NgInx
完成,但可能有一个嵌入式选项。我已经阅读了文档以及 GitHub issues/pull-request 但我没有找到任何相关主题。默认情况下是不可能的,那么我对基于 NgInx
的解决方案持开放态度。
我已经成功解决了 1.0.0-alpha.4
Docker 图像版本的问题。
docker-compose.yml
中的服务:
mongo-express:
container_name: mongo-express
hostname: mongo-express
image: mongo-express:1.0.0-alpha.4
depends_on:
- mongo1
- mongo2
networks:
- mongo_net
volumes:
- ./certs/domain.crt:/public.crt
- ./certs/domain.key:/domain.key
environment:
- ME_CONFIG_MONGODB_URL=mongodb://admin:admin_pwd@mongo1:27017,mongo2:27017/?replicaSet=my-replica-set
- ME_CONFIG_BASICAUTH_USERNAME=admin
- ME_CONFIG_BASICAUTH_PASSWORD=admin_pwd
- ME_CONFIG_OPTIONS_EDITORTHEME=night
- ME_CONFIG_SITE_SSL_ENABLED=true
- ME_CONFIG_MONGODB_ENABLE_ADMIN=true
- ME_CONFIG_SITE_SSL_CRT_PATH=/public.crt
- ME_CONFIG_SITE_SSL_KEY_PATH=/domain.key
ports:
- '8081:8081'
restart: on-failure
deploy:
mode: replicated
replicas: 1
placement:
constraints: [ node.role == manager ]
logging:
driver: "fluentd"
options:
fluentd-address: ${SYSTEM_HOST}:24224
tag: mongo-express
通过上述服务配置,mongo-express
将在 https://localhost:8081
站点上 运行。
注意:
管理功能在 1.0.0-alpha.4
或 latest
Docker 图像中不可用,即使 ME_CONFIG_MONGODB_ENABLE_ADMIN
参数设置为 true
。该错误是已知的,并且已在 GitHub 上多次报告。例如:https://github.com/mongo-express/mongo-express/issues/647。我正在等待修复...
是否可以选择使用域 CERT(使用 HTTPS)和 docker 组合来部署 mongo-express
服务?我有一个带有 CERT 的现有网站(它使用 HTTPS),我想将 mongo-express
集成到它。所以我想将其部署为 https://my_host:8081
.
我当前的测试 docker-compose.yml
文件运行完美,但它使用 HTTP 协议 (http://localhost:8081
)。
我当前的测试docker-compose.yml
文件:
version: "3.8"
services:
db:
container_name: mongo-dev
hostname: mongo-dev
image: mongo:4.2
environment:
- MONGO_INITDB_ROOT_USERNAME=admin
- MONGO_INITDB_DATABASE=auth
- MONGO_INITDB_ROOT_PASSWORD=pass
networks:
- mongo-compose-network
ports:
- '27017:27017'
volumes:
- ./data:/data/db
mongo-express:
container_name: mongo-express
image: mongo-express:0.54.0
depends_on:
- db
networks:
- mongo-compose-network
environment:
- ME_CONFIG_MONGODB_SERVER=mongo-dev
- ME_CONFIG_MONGODB_ADMINUSERNAME=admin
- ME_CONFIG_MONGODB_ADMINPASSWORD=pass
- ME_CONFIG_BASICAUTH_USERNAME=admin
- ME_CONFIG_BASICAUTH_PASSWORD=tribes
ports:
- '8081:8081'
restart: on-failure
networks:
mongo-compose-network:
driver: bridge
我知道可以用 NgInx
完成,但可能有一个嵌入式选项。我已经阅读了文档以及 GitHub issues/pull-request 但我没有找到任何相关主题。默认情况下是不可能的,那么我对基于 NgInx
的解决方案持开放态度。
我已经成功解决了 1.0.0-alpha.4
Docker 图像版本的问题。
docker-compose.yml
中的服务:
mongo-express:
container_name: mongo-express
hostname: mongo-express
image: mongo-express:1.0.0-alpha.4
depends_on:
- mongo1
- mongo2
networks:
- mongo_net
volumes:
- ./certs/domain.crt:/public.crt
- ./certs/domain.key:/domain.key
environment:
- ME_CONFIG_MONGODB_URL=mongodb://admin:admin_pwd@mongo1:27017,mongo2:27017/?replicaSet=my-replica-set
- ME_CONFIG_BASICAUTH_USERNAME=admin
- ME_CONFIG_BASICAUTH_PASSWORD=admin_pwd
- ME_CONFIG_OPTIONS_EDITORTHEME=night
- ME_CONFIG_SITE_SSL_ENABLED=true
- ME_CONFIG_MONGODB_ENABLE_ADMIN=true
- ME_CONFIG_SITE_SSL_CRT_PATH=/public.crt
- ME_CONFIG_SITE_SSL_KEY_PATH=/domain.key
ports:
- '8081:8081'
restart: on-failure
deploy:
mode: replicated
replicas: 1
placement:
constraints: [ node.role == manager ]
logging:
driver: "fluentd"
options:
fluentd-address: ${SYSTEM_HOST}:24224
tag: mongo-express
通过上述服务配置,mongo-express
将在 https://localhost:8081
站点上 运行。
注意:
管理功能在 1.0.0-alpha.4
或 latest
Docker 图像中不可用,即使 ME_CONFIG_MONGODB_ENABLE_ADMIN
参数设置为 true
。该错误是已知的,并且已在 GitHub 上多次报告。例如:https://github.com/mongo-express/mongo-express/issues/647。我正在等待修复...