Я разворачиваю mongodb и nginx через docker (docker compose), но не удается подключиться к mongo через mongoDB Compass к примеру ( внешнее подключение ), получаю следующую ошибку (текущая):
Invalid message size: 1347703880, max allowed: 67108864
Мой docker-compose.yml
version: '3.9'
services:
nginx:
image: nginx:latest
container_name: nginx
ports:
- '80:80'
- '443:443'
volumes:
- ./.config/nginx-server/nginx.conf:/etc/nginx/conf.d/nginx.conf
- /certbot/conf:/etc/letsencrypt
- /certbot/www:/var/www/certbot
networks:
- nginx_net
restart: unless-stopped
command: '/bin/sh -c ''while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g "daemon off;"'''
mongo:
image: mongo:4.4.6
container_name: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=${MONGO_USERNAME}
- MONGO_INITDB_ROOT_PASSWORD=${MONGO_PASSWORD}
- MONGO_INITDB_DATABASE=${MONGO_DATABASE}
volumes:
- ./.config/mongodb/mongod.conf:/etc/mongod.conf
- ./.config/mongodb/mongo-init.sh:/docker-entrypoint-initdb.d/mongo-init.sh:ro
restart: unless-stopped
ports:
- '27517:27517'
networks:
- nginx_net
- mongodb_net
entrypoint:
[
'bash',
'-c',
'bash /docker-entrypoint-initdb.d/mongo-init.sh',
'/usr/bin/mongod',
'--config',
'/etc/mongod.conf'
]
networks:
nginx_net:
mongodb_net:
name: mongodb
driver: bridge
Мой nginx.conf:
upstream mongo {
server mongo:27517 fail_timeout=0;
}
server {
listen 80;
listen 443 ssl;
http2 on;
server_name mongodb.domain.ru;
ssl_certificate /etc/letsencrypt/live/mongodb.domain.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mongodb.domain.ru/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
if ($server_port = 80) { set $https_redirect 1; }
if ($host ~ '^www\.') { set $https_redirect 1; }
if ($https_redirect = 1) { return 301 https://$host$request_uri; }
location / {
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect http:// https://;
proxy_pass http://mongo;
# Required for new HTTP-based CLI
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_buffering off; # Required for HTTP-based CLI to work over SSL
}
location /.well-known/acme-challenge/ { root /var/www/certbot; }
}
Мой mongod.conf
net:
bindIp: 127.0.0.1
security:
authorization: enabled
Строка подключения: mongodb.domain.ru:80
MongoDB и Nginx стартуют без ошибок