
我有一個 redis 資料庫。現在我需要讓它在本地工作。我的意思是我希望它只能在我的本機電腦上存取。沒有透過網路的請求。我該怎麼做?
我找到了redis.conf,內容如下:
# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
bind 127.0.0.1
Rowbind 127.0.0.1
之前評論過。我使用 重新啟動了 redis service redis restart
,但我仍然可以透過網路從 redis 讀取資料。
答案1
將組態選項“protected-mode”設定為“yes”,並保留“bind”選項的註解:
bind 127.0.0.1
rotected-mode yes
然後確保您正在運行的redis-server
實例以您正在修改的配置啟動。停止實例並使用以下命令手動運行它:
redis-server /path/to/your/redis.conf
Redis 將以前台和詳細模式運作(顯示漂亮的 ASCII 藝術)。然後照常檢查其綁定位址:
# netstat -nap|egrep redis
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 30772/redis-server