Unverified Commit 2eea0b32 authored by Fongang Rodrique's avatar Fongang Rodrique Committed by gitbook-bot
Browse files

GitBook: [#1583] MongoDB URI Authentication

parent 935319e0
......@@ -77,6 +77,7 @@
* [Supported NodeJs Version](quick-start/environment-configuration/node-configuration/supported-nodejs-version.md)
* [Runtime Configuration](quick-start/environment-configuration/node-configuration/runtime-configuration.md)
* [MongoDB Configuration](quick-start/environment-configuration/mongodb-configuration.md)
* [MongoDB URI Authentication](quick-start/environment-configuration/mongodb-configuration/mongodb-uri-authentication.md)
* [Passing extra options to the Mongo driver](quick-start/installing-and-updating/other-deployment-methods/manual-installation/extras/mongo-options.md)
* [Configure a replica set for MongoDB](quick-start/installing-and-updating/other-deployment-methods/manual-installation/extras/mongo-replicas.md)
* [Migrating database from Meteor built in MongoDB](quick-start/installing-and-updating/other-deployment-methods/manual-installation/extras/migrating-meteor-mongo.md)
......
# MongoDB URI Authentication
The connection between Rocket.Chat and MongoDB instance is achieved using a [MongoDB Connection String URI](https://www.mongodb.com/docs/manual/reference/connection-string/). MongoDB authentication is done with the username and password.
Adding the following snippet in your `env` does the trick.
```
MONGO_URL=mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
```
In your container, passing in `MONGO_URL` and `MONGO_OPLOG_URL` with the right values for connection.
{% hint style="info" %}
Depending on the password you're using, you might need to escape some characters, for example.. Please take a look at MongoDB documentation [https://docs.mongodb.com/manual/reference/connection-string/](https://docs.mongodb.com/manual/reference/connection-string/)
{% endhint %}
Your `docker-compose.yml` file should look like this
```
environment:
- "MONGO_URL=mongodb://rctestuser:mymongopassword@mongo:27017/rocketchat?authSource=admin"
- "MONGO_OPLOG_URL=mongodb://rctestuser:mymongopassword@mongo:27017/local?authSource=admin"
```
If using `docker run`, it should look like this:
```
docker run \ -e "MONGO_URL=mongodb://rctestuser:mymongopassword@mongo:27017/rocketchat?authSource=admin" \
-e "MONGO_OPLOG_URL=mongodb://rctestuser:mymongopassword@mongo:27017/local?authSource=admin" \
rocketchat/rocket.chat:X.X.X
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment