Heim  >  Artikel  >  Datenbank  >  So machen Sie Redis aus der Ferne zugänglich

So machen Sie Redis aus der Ferne zugänglich

王林
王林nach vorne
2021-02-01 10:08:022003Durchsuche

So machen Sie Redis aus der Ferne zugänglich

Einführung:

Wir alle wissen, dass Redis standardmäßig nur lokalen Zugriff zulässt. Was sollten wir also tun, wenn wir den Fernzugriff auf Redis aktivieren möchten?

Spezifische Methode:

Öffnen Sie die Datei redis.conf wie im Abschnitt NETZWERK erläutert

################################## NETWORK #####################################
 
# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

Lösung: Kommentieren Sie bind 127.0.0.1 aus, um allen IPs den Zugriff auf Redis zu ermöglichen

Wenn Sie mehrere IPs für den Zugriff angeben möchten, aber nicht alle Um auf die IP zuzugreifen, können Sie binden Greifen Sie erneut auf Redisd zu. Es wird immer noch ein Fehler wie folgt gemeldet:

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes

Verwandte Empfehlungen:

Redis-Datenbank-Tutorial

Das obige ist der detaillierte Inhalt vonSo machen Sie Redis aus der Ferne zugänglich. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:cnblogs.com. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen