Skip to content

How to restrict external access to Redis instance installed in a docker image

Solved Configure
8 3 3.4k 1
  • Hello, I’m receiving an email, about my server that has a docker image of redis installed and uses port 6379, saying that it is open to external connections.

    Redis listens for traffic from everywhere on port 6379, and you can validate this report by attempting to connect to your Redis on 6379 via a simple telnet command:

    telnet 111.111.111.111 6379 
    

    This is a part of the email, (I masked the IP to put the message here on the forum) I also did the test to see if the port is really open to external connections on the website, https://www.yougetsignal.com /tools/open-ports/ , and it actually shows that my server’s ip port 6379 is open. And the email says to do the following

    Remediation of this issue will take just a few minutes and is relatively straightforward. You will need to open /etc/redis/redis.conf and uncomment (remove the “#”) or modify the line beginning with:

    #bind 127.0.0.1 ::1  
    

    Afterwards, restart redis with:

    sudo systemctl restart redis  
    

    I would like to know if someone can help me, since I can’t access the redis.config file inside the server, because redis is in a docker image, or at least I don’t know how to access it. Is there any way to block external access to my redis installed by a docker image?

  • @phenomlab
    Sorry to delay in responding, yes as i mentioned above, i had to remove my redis from docker and reinstall a new image with this command

    docker run --name=redis -p 127.0.0.1:6379:6379 -d -t redis:alpine
    

    and now when i test my ip and port on
    https://www.yougetsignal.com/tools/open-ports/

    the status of my redis port is closed. I think which to configure firewall in droplet digital ocean is a good idea too, and i will configure soon.
    Thanks for the help!

  • Hello, I’m receiving an email, about my server that has a docker image of redis installed and uses port 6379, saying that it is open to external connections.

    Redis listens for traffic from everywhere on port 6379, and you can validate this report by attempting to connect to your Redis on 6379 via a simple telnet command:

    telnet 111.111.111.111 6379 
    

    This is a part of the email, (I masked the IP to put the message here on the forum) I also did the test to see if the port is really open to external connections on the website, https://www.yougetsignal.com /tools/open-ports/ , and it actually shows that my server’s ip port 6379 is open. And the email says to do the following

    Remediation of this issue will take just a few minutes and is relatively straightforward. You will need to open /etc/redis/redis.conf and uncomment (remove the “#”) or modify the line beginning with:

    #bind 127.0.0.1 ::1  
    

    Afterwards, restart redis with:

    sudo systemctl restart redis  
    

    I would like to know if someone can help me, since I can’t access the redis.config file inside the server, because redis is in a docker image, or at least I don’t know how to access it. Is there any way to block external access to my redis installed by a docker image?

    @WesleyMoura Hi, and welcome to Sudonix. Even with Redis installed in a docker image, you will still have a config file, and should still be able to reach it.

    Can you provide more detail about the docket image ? You are right - by default, Redis will listen on all addresses, and will be exposed to the internet. Another way around this is to block access at firewall level and only permit the hosts you actually want.

  • @WesleyMoura Hi, and welcome to Sudonix. Even with Redis installed in a docker image, you will still have a config file, and should still be able to reach it.

    Can you provide more detail about the docket image ? You are right - by default, Redis will listen on all addresses, and will be exposed to the internet. Another way around this is to block access at firewall level and only permit the hosts you actually want.

    @phenomlab Hello, i have installed my redis on docker with this comand,
    docker run --name redis -p 6379:6379 -d -t redis:alpine
    And i don’t know how to access the redis.conf on docker image to make this step cited in email.
    Do you know how to do?
    I’m trying to search on documentation but i still can’t find it.

  • @phenomlab Hello, i have installed my redis on docker with this comand,
    docker run --name redis -p 6379:6379 -d -t redis:alpine
    And i don’t know how to access the redis.conf on docker image to make this step cited in email.
    Do you know how to do?
    I’m trying to search on documentation but i still can’t find it.

    @WesleyMoura Is it located in /usr/local/etc/redis/redis.conf ?

    Also, have a look at this

    https://hub.docker.com/_/redis

  • 6a81d494-bcc6-404d-8f2a-bef1e530314d-image.png

    Hello Wesley, i am doing great thanks for asking.

    actually, i am using digital ocean droplet with Plesk + Redis with docker

    i followed this guide and it solved the issue https://talk.plesk.com/threads/plesk-docker-redis-plesk-firewall-open-port-issue.352324/

    we need to install Redis docker using Plesk store BUT should run it using a specific command that limits its access to the local host only. (in your case you will install redis using command)

    Start the docker with,

    docker run --name=redis -p 127.0.0.1:6379:6379 redis
    

    d488b58b-e427-4c4e-9003-55ee1e1b35f9-image.png

    not sure this helps you or not but play with above command 😄

  • @phenomlab Hello, i have installed my redis on docker with this comand,
    docker run --name redis -p 6379:6379 -d -t redis:alpine
    And i don’t know how to access the redis.conf on docker image to make this step cited in email.
    Do you know how to do?
    I’m trying to search on documentation but i still can’t find it.

    @WesleyMoura any update ?

  • 6a81d494-bcc6-404d-8f2a-bef1e530314d-image.png

    Hello Wesley, i am doing great thanks for asking.

    actually, i am using digital ocean droplet with Plesk + Redis with docker

    i followed this guide and it solved the issue https://talk.plesk.com/threads/plesk-docker-redis-plesk-firewall-open-port-issue.352324/

    we need to install Redis docker using Plesk store BUT should run it using a specific command that limits its access to the local host only. (in your case you will install redis using command)

    Start the docker with,

    docker run --name=redis -p 127.0.0.1:6379:6379 redis
    

    d488b58b-e427-4c4e-9003-55ee1e1b35f9-image.png

    not sure this helps you or not but play with above command 😄

    @Hari said in How to restrict external access to Redis instance installed in a docker image:

    Hello Hari, sorry my delay in responding, but i already solved this problem, using exactly this command that you mentioned, docker run --name=redis -p 127.0.0.1:6379:6379 -d -t redis:alpine, in my case. But as i already had one image of redis, i had to remove the current redis from my docker and reinstall using this comand. Now when i test the port on https://www.yougetsignal.com/tools/open-ports/ with my ip and port of redis, the status of port is closed now. And now i just have to configure my firewall wich i will soon.
    So thanks to answer me and sorry again to delay in responding.

  • @phenomlab
    Sorry to delay in responding, yes as i mentioned above, i had to remove my redis from docker and reinstall a new image with this command

    docker run --name=redis -p 127.0.0.1:6379:6379 -d -t redis:alpine
    

    and now when i test my ip and port on
    https://www.yougetsignal.com/tools/open-ports/

    the status of my redis port is closed. I think which to configure firewall in droplet digital ocean is a good idea too, and i will configure soon.
    Thanks for the help!

  • phenomlabundefined phenomlab has marked this topic as solved on

Did this solution help you?
Did you find the suggested solution useful? Support 💗 Sudonix with a coffee
If your organisation needs deeper expertise around infrastructure, security, or technology leadership, learn more about Phenomlab Ltd. Many of the deeper technical guides behind Sudonix are published there.

Related Topics
  • 3 Votes
    4 Posts
    2k Views
    I’ve been using this service for a couple of days now, and it’s made my internet access so much faster. That alone is a plus, and I never thought there would be a contender for Cloudflare in this area.
  • 0 Votes
    4 Posts
    1k Views
    @DownPW most of this really depends on your desired security model. In all cases with firewalls, less is always more, although it’s never as clear cut as that, and there are always bespoke ports you’ll need to open periodically. Heztner’s DDoS protection is superior, and I know they have invested a lot of time, effort, and money into making it extremely effective. However, if you consider that the largest ever DDoS attack hit Cloudflare at 71m rps (and they were able to deflect it), and each attack can last anywhere between 8-24 hours which really depends on how determined the attacker(s) is/are, you can never be fully prepared - nor can you trace it’s true origin. DDoS attacks by their nature (Distributed Denial of Service) are conducted by large numbers of devices whom have become part of a “bot army” - and in most cases, the owners of these devices are blissfully unaware that they have been attacked and are under command and control from a nefarious resource. Given that the attacks originate from multiple sources, this allows the real attacker to observe from a distance whilst concealing their own identity and origin in the process. If you consider the desired effect of DDoS, it is not an attempt to access ports that are typically closed, but to flood (and eventually overwhelm) the target (such as a website) with millions of requests per second in an attempt to force it offline. Victims of DDoS attacks are often financial services for example, with either extortion or financial gain being the primary objective - in other words, pay for the originator to stop the attack. It’s even possible to get DDoS as a service these days - with a credit card, a few clicks of a mouse and a target IP, you can have your own proxy campaign running in minutes which typically involves “booters” or “stressers” - see below for more https://heimdalsecurity.com/blog/ddos-as-a-service-attacks-what-are-they-and-how-do-they-work @DownPW said in Setting for high load and prevent DDoS (sysctl, iptables, crowdsec or other): in short if you have any advice to give to secure the best. It’s not just about DDos or firewalls. There are a number of vulnerabilities on all systems that if not patched, will expose that same system to exploit. One of my favourite online testers which does a lot more than most basic ones is below https://www.immuniweb.com/websec/ I’d start with the findings reported here and use that to branch outwards.
  • www. Infront stops website access?

    Solved Configure nodebb
    10
    1 Votes
    10 Posts
    1k Views
    @Panda because there is no match for the DNS entry specified. The receiving web server parses the headers looking for a destination hostname to match, and anything the web server is unable to resolve will be sent back to the root.
  • NodeBB 3.0 alpha1 : Error on install

    Solved Configure nodebb version 3 install error
    19
    2 Votes
    19 Posts
    3k Views
    @phenomlab Work now
  • 19 Votes
    30 Posts
    4k Views
    @phenomlab 100%.
  • 3 Votes
    4 Posts
    2k Views
    @DownPW yeah, I seem to spend a large amount of my time trying to educate people that there’s no silver bullet when it comes to security.
  • Addressing vulnerability management

    Blog security vulnerability
    1
    1
    0 Votes
    1 Posts
    582 Views
    No one has replied
  • Digitalocean Ubuntu configuration

    Solved Linux
    33
    12 Votes
    33 Posts
    6k Views
    @phenomlab thank you! not me