Keep MongoDB off the Internet and its password out of git
MongoDB was published on 0.0.0.0:27017 with the default "example" root password. It now listens on 127.0.0.1 only (the apps use the Docker network), and the root password comes from MONGO_PASSWORD in a git-ignored .env file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ad82a96440
commit
0d6f8d95c3
@@ -15,3 +15,6 @@ static/device_snapshots/
|
|||||||
|
|
||||||
# Config locale spécifique à cette machine
|
# Config locale spécifique à cette machine
|
||||||
.claude/
|
.claude/
|
||||||
|
|
||||||
|
# Mot de passe MongoDB (variables de docker-compose)
|
||||||
|
.env
|
||||||
|
|||||||
+5
-3
@@ -5,10 +5,12 @@ services:
|
|||||||
image: mongo:latest
|
image: mongo:latest
|
||||||
container_name: mongodb
|
container_name: mongodb
|
||||||
ports:
|
ports:
|
||||||
- "27017:27017"
|
# Seulement depuis la machine elle-même : les applications passent par le réseau Docker
|
||||||
|
- "127.0.0.1:27017:27017"
|
||||||
environment:
|
environment:
|
||||||
MONGO_INITDB_ROOT_USERNAME: root
|
MONGO_INITDB_ROOT_USERNAME: root
|
||||||
MONGO_INITDB_ROOT_PASSWORD: example
|
# Mot de passe dans .env (MONGO_PASSWORD), hors du dépôt git
|
||||||
|
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD:?MONGO_PASSWORD manquant dans .env}
|
||||||
volumes:
|
volumes:
|
||||||
- mongodb_data:/data/db
|
- mongodb_data:/data/db
|
||||||
networks:
|
networks:
|
||||||
@@ -20,7 +22,7 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- mongodb
|
- mongodb
|
||||||
environment:
|
environment:
|
||||||
- MONGO_URI=mongodb://root:example@mongodb:27017/?authSource=admin
|
- MONGO_URI=mongodb://root:${MONGO_PASSWORD:?MONGO_PASSWORD manquant dans .env}@mongodb:27017/?authSource=admin
|
||||||
networks:
|
networks:
|
||||||
- app-network
|
- app-network
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
Reference in New Issue
Block a user