gpt4 book ai didi

javascript - 使用依赖注入(inject) nodejs 的密码保护 REDIS

转载 作者:IT王子 更新时间:2023-10-29 06:06:13 25 4
gpt4 key购买 nike

大家好,我的 Redis 设置依赖注入(inject)有问题。我们有一个用于开发的室外中央 Redis 服务器,因此在我的主文件 (app.js) 中,我正在尝试将其连接到服务器。现在,这是受密码保护的,找不到问题所在。

我正在使用这个模块 redis

应用程序.js

let redis = require('redis');
let redisSettings = {
host: settings.redis.ip,
port: settings.redis.port,
parser: settings.redis.parser,
password: settings.redis.password
};

let redisClient = redis.createClient(redisSettings);
redisClient.auth(settings.redis.password, function(){
});

let routes = require('./routes')( redisClient);

设置.js

module.exports = {
redis: {
ip: 'domainname.example',
port: '6379',
parser: 'javascript',
password: 'our_very_secure_password'
}
}

错误页面

events.js:182 throw er; // Unhandled 'error' event ^

ReplyError: DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected- mode no' from the loopback interface by connecting to Redis from the same host the server is running, , however, MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside. at parseError (/Users/joey.dossche/Documents/DEV/koha_goan/node_modules/redis- parser/lib/parser.js:193:12) at parseType (/Users/joey.dossche/Documents/DEV/koha_goan/node_modules/redis- parser/lib/parser.js:303:14)

[nodemon] app crashed - waiting for file changes before starting...

最佳答案

错误日志中包含 4 种可能的问题解决方案。您可以使用对您来说最方便的那个。

关于javascript - 使用依赖注入(inject) nodejs 的密码保护 REDIS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46711981/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com