Add custom Mongo Express config to disable auth

This commit is contained in:
berkay 2025-04-19 19:36:41 +03:00
parent f38cf5f495
commit f20610df8b
2 changed files with 58 additions and 6 deletions

View File

@ -39,6 +39,8 @@ services:
container_name: mongo-express
hostname: mongo-express
restart: always
volumes:
- ./mongo-express-config.js:/node_modules/mongo-express/config.js:ro
environment:
- ME_CONFIG_MONGODB_ADMINUSERNAME=${MONGO_ROOT_USERNAME:-admin}
- ME_CONFIG_MONGODB_ADMINPASSWORD=${MONGO_ROOT_PASSWORD:-password}
@ -46,12 +48,9 @@ services:
- ME_CONFIG_MONGODB_AUTH_DATABASE=admin
# Fix connection string format
- ME_CONFIG_MONGODB_URL=mongodb://${MONGO_ROOT_USERNAME:-admin}:${MONGO_ROOT_PASSWORD:-password}@mongodb:27017/?authSource=admin
# Disable basic authentication for easier access
# - ME_CONFIG_BASICAUTH_USERNAME=${MONGOEXPRESS_USERNAME:-mexpress}
# - ME_CONFIG_BASICAUTH_PASSWORD=${MONGOEXPRESS_PASSWORD:-mexpress}
- ME_CONFIG_MONGODB_ENABLE_ADMIN=true
# Remove the base URL path so it works at root path
# - ME_CONFIG_SITE_BASEURL=/mongo-express
# Explicitly disable basic auth
- ME_CONFIG_BASICAUTH_USERNAME=
- ME_CONFIG_BASICAUTH_PASSWORD=
ports:
- "8081:8081" # Expose Mongo Express web interface to external machines
depends_on:

53
mongo-express-config.js Normal file
View File

@ -0,0 +1,53 @@
'use strict';
// Custom Mongo Express configuration
module.exports = {
mongodb: {
// Connection string for MongoDB
connectionString: process.env.ME_CONFIG_MONGODB_URL || '',
// MongoDB server options
admin: true,
// MongoDB authentication options
adminUsername: process.env.ME_CONFIG_MONGODB_ADMINUSERNAME || 'admin',
adminPassword: process.env.ME_CONFIG_MONGODB_ADMINPASSWORD || 'password',
// Auth database name
auth: [
{
database: process.env.ME_CONFIG_MONGODB_AUTH_DATABASE || 'admin',
username: process.env.ME_CONFIG_MONGODB_ADMINUSERNAME || 'admin',
password: process.env.ME_CONFIG_MONGODB_ADMINPASSWORD || 'password',
}
]
},
// Web server options
site: {
// Base URL path
baseUrl: '/',
// Web server port
port: process.env.ME_CONFIG_SITE_PORT || 8081,
// Web server host
host: '0.0.0.0'
},
// Options for basic authentication
basicAuth: {
// Disable basic authentication
username: '',
password: ''
},
// Other options
options: {
// Enable editing
editMode: true,
// Enable admin mode
adminMode: true
}
};