-
-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Secure MongoDB and Redis #266
Closed
noliveleger
wants to merge
31
commits into
kobo-install-two-databases
from
two-databases-secured-backend
Closed
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
b7be5c3
Added network for backend and updated frontend images
noliveleger 785dff2
Moved network settings to master and slave composer files
noliveleger 77bd82c
Updated README: security & firewall
noliveleger 7cfd809
Create authenticated MongoDB user on DB init
noliveleger 9f9e6f2
Added password to redis configuration files
noliveleger 2ffc651
Merge branch 'kobo-install-two-databases' into two-databases-secured-…
noliveleger 6723091
Use envsub instead of sed to create redis conf
noliveleger 05f45cf
Escaped double quote in Redis password
noliveleger dcf258c
Updated env files templates
noliveleger 17ee6d2
Added scripts for MongoDB and PostgreSQL that run at boot to update u…
noliveleger 5149fa1
Merge branch 'kobo-install-two-databases' into two-databases-secured-…
noliveleger 82a65cc
Fixed typo in MongoDB upsert_db_user script
noliveleger f34eac2
Ports are not exposed anymore by default:
noliveleger c2d068a
Support authentication with MongoDB backups
noliveleger fcbb5d1
Updated postgres toggle backup script
noliveleger 6e60e03
Upgraded S3 backup virtualenv to Python3
noliveleger eed0a4a
Replaced "which" with "command -v"
noliveleger c098517
Use "command -v" instead of harcoded path for "pg_ctl"
noliveleger 3c82d2e
Use persistent storage for KPI FileFields
jnm b98a0d2
Give database servers a grace period to stop
jnm 8a1ad16
Modify entrypoint scripts to pass friendly signals
jnm 36b79ef
Succumb to perfectionism
jnm 2c00700
Merge pull request #230 from kobotoolbox/kobo-install-two-databases
jnm 1f6fab5
Add note about shared-database branch to README
jnm 0773bc9
Merge pull request #279 from kobotoolbox/add-shared-database-note-to-…
jnm 04fdf50
Upgrade KoBoCAT to 2.020.18
jnm b5cd7ce
Upgrade KPI to 2.020.18
jnm fb661e8
Merge pull request #277 from kobotoolbox/275-persistent-kpi-filefield…
jnm b159e71
Merge pull request #278 from kobotoolbox/276-pass-signals-to-database…
jnm 03c9def
Merge branch 'master' into two-databases-secured-backend
noliveleger 86d91d3
Fixed typo
noliveleger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/oleger/kobo-docker-data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/home/oleger/kobo-docker-data/.backups/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,11 @@ | |
# Please see kobocat.txt to set container variables | ||
KOBO_MONGO_PORT=27017 | ||
KOBO_MONGO_HOST=mongo.domain.name | ||
MONGO_INITDB_ROOT_USERNAME=root | ||
MONGO_INITDB_ROOT_PASSWORD=kobo | ||
MONGO_INITDB_DATABASE=formhub | ||
KOBO_MONGO_USERNAME=kobo | ||
KOBO_MONGO_PASSWORD=kobo | ||
|
||
# Default MongoDB backup schedule is weekly at 01:00 AM UTC on Sunday. | ||
#MONGO_BACKUP_SCHEDULE=0 1 * * 0 | ||
|
@@ -20,12 +25,14 @@ KOBO_MONGO_HOST=mongo.domain.name | |
# `DATABASE_URL` environment variable. | ||
POSTGRES_PORT=5432 | ||
POSTGRES_HOST=postgres.domain.name | ||
POSTGRES_DB=kobotoolbox | ||
POSTGRES_USER=kobo | ||
POSTGRES_PASSWORD=kobo | ||
KC_POSTGRES_DB=kobocat | ||
KPI_POSTGRES_DB=koboform | ||
|
||
# Postgres database used by kpi and kobocat Django apps | ||
DATABASE_URL=postgis://kobo:[email protected]:5432/kobotoolbox | ||
KC_DATABASE_URL=postgis://kobo:[email protected]:5432/kobotoolbox | ||
KPI_DATABASE_URL=postgis://kobo:[email protected]:5432/kobotoolbox | ||
|
||
# Replication. Password is mandatory | ||
KOBO_POSTGRES_REPLICATION_USER=kobo_replication | ||
|
@@ -41,3 +48,6 @@ KOBO_POSTGRES_MASTER_ENDPOINT=primary.postgres.domain.name | |
#-------------------------------------------------------------------------------- | ||
|
||
#REDIS_BACKUP_SCHEDULE=0 3 * * 0 | ||
|
||
REDIS_SESSION_URL=redis://:[email protected]:6390/2 | ||
REDIS_PASSWORD=kobo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# For public, HTTPS servers. | ||
version: '2.2' | ||
|
||
services: | ||
|
||
postgres: | ||
#environment: | ||
# - POSTGRES_BACKUP_FROM_SLAVE=True | ||
# Uncomment `ports` section if you want to expose ports (e.g. use as separated servers) | ||
#ports: | ||
# - 5432:5432 | ||
# Comment out `networks` section below if you want to expose ports | ||
networks: | ||
kobo-be-network: | ||
aliases: | ||
- postgres.kobo.private | ||
|
||
mongo: | ||
# Uncomment `ports` section if you want to expose ports (e.g. use as separated servers) | ||
#ports: | ||
# - 27017:27017 | ||
# Comment out section below if you want to expose ports | ||
networks: | ||
kobo-be-network: | ||
aliases: | ||
- mongo.kobo.private | ||
|
||
redis_main: | ||
# Uncomment `ports` section if you want to expose ports (e.g. use as separated servers) | ||
#ports: | ||
# - 6379:6379 | ||
# Comment out `networks` section below if you want to expose ports | ||
networks: | ||
kobo-be-network: | ||
aliases: | ||
- redis-main.kobo.private | ||
|
||
redis_cache: | ||
# Uncomment `ports` section if you want to expose ports (e.g. use as separated servers) | ||
#ports: | ||
# - 6380:6380 | ||
# Comment out `networks` section below if you want to expose ports | ||
networks: | ||
kobo-be-network: | ||
aliases: | ||
- redis-cache.kobo.private |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# For public, HTTPS servers. | ||
version: '3' | ||
|
||
services: | ||
kobocat: | ||
environment: | ||
# change `ENKETO_PROTOCOL` to http if HTTPS is not used | ||
- ENKETO_PROTOCOL=https | ||
# `NGINX_PUBLIC_PORT` is the port used to access KoBoToolbox (e.g. `https://kc.kobotoolbox.org:<NGINX_PUBLIC_PORT>`) | ||
- NGINX_PUBLIC_PORT=80 | ||
# Uncomment the lines below to tweak uWSGI | ||
#- KC_UWSGI_WORKERS_COUNT=2 | ||
#- KC_UWSGI_CHEAPER_WORKERS_COUNT=1 | ||
#- KC_UWSGI_MAX_REQUESTS=512 | ||
#- KC_UWSGI_CHEAPER_RSS_LIMIT_SOFT=134217728 | ||
networks: | ||
kobo-be-network: | ||
aliases: | ||
- kobocat | ||
- kobocat.docker.container | ||
|
||
kpi: | ||
environment: | ||
# `NGINX_PUBLIC_PORT` is the port used to access KoBoToolbox (e.g. `https://kf.kobotoolbox.org:<NGINX_PUBLIC_PORT>`) | ||
- NGINX_PUBLIC_PORT=80 | ||
# Uncomment the lines below to tweak uWSGI | ||
#- KPI_UWSGI_WORKERS_COUNT=2 | ||
#- KPI_UWSGI_CHEAPER_WORKERS_COUNT=1 | ||
#- KPI_UWSGI_MAX_REQUESTS=512 | ||
#- KPI_UWSGI_CHEAPER_RSS_LIMIT_SOFT=134217728 | ||
# Comment out the line below if HTTPS is not used | ||
- SECURE_PROXY_SSL_HEADER=HTTP_X_FORWARDED_PROTO, https | ||
networks: | ||
kobo-be-network: | ||
aliases: | ||
- kpi | ||
- kpi.docker.container | ||
|
||
nginx: | ||
environment: | ||
# `NGINX_PUBLIC_PORT` is the port used to access KoBoToolbox (e.g. `https://kf.kobotoolbox.org:<NGINX_PUBLIC_PORT>`) | ||
- NGINX_PUBLIC_PORT=80 | ||
ports: | ||
# <proxy_port>:80 . If no proxies, `proxy_port` should be the same as `NGINX_PUBLIC_PORT` | ||
- 80:80 | ||
networks: | ||
kobo-fe-network: | ||
aliases: | ||
- nginx | ||
# These aliases must match the concatenation of `*_PUBLIC_SUBDOMAIN` and `INTERNAL_DOMAIN_NAME` | ||
# found in `../kobo-deployments/envfile.txt` | ||
- kf.docker.internal | ||
- kc.docker.internal | ||
- ee.docker.internal | ||
|
||
enketo_express: | ||
networks: | ||
kobo-be-network: | ||
aliases: | ||
- enketo_express | ||
|
||
networks: | ||
kobo-be-network: | ||
external: | ||
# name: <prefix>_kobo-be-network`, where `prefix` is usually the parent | ||
# folder name | ||
name: kobodocker_kobo-be-network |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jnm If you look at
docker-compose.frontend.override.yml.sample
, you can see thatkpi
,kc
andee
are also using this network. Because backend and frontend containers are not declared in the same composer file, frontend containers need to know what is the name of backend containers network (when ports are not exposed).