Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

agnos.is Forums

  1. Home
  2. Selfhosted
  3. What steps do you take to secure your server and your selfhosted services?

What steps do you take to secure your server and your selfhosted services?

Scheduled Pinned Locked Moved Selfhosted
selfhosted
58 Posts 32 Posters 470 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G [email protected]

    ez pz:

    #!/usr/sbin/nft -f
    table inet filter {
        chain input {
            type filter hook input priority raw; policy accept;
            iif "lo" accept
            ct state established,related accept
            iif "enp1s0" udp dport 51820 accept
            iif "enp1s0" drop
        }
    
        chain forward {
            type filter hook forward priority raw; policy accept;
            iif "lo" accept
            ct state established,related accept
            iif "enp1s0" udp dport 51820 accept
            iif "enp1s0" drop
        }
    
        chain output {
            type filter hook output priority raw; policy accept;
        }
    }
    
    irmadlad@lemmy.worldI This user is from outside of this forum
    irmadlad@lemmy.worldI This user is from outside of this forum
    [email protected]
    wrote on last edited by
    #29

    I've seen it done as such:

    1 Reply Last reply
    0
    • O [email protected]

      Inspired by this comment to try to learn what I'm missing.

      • Cloudflare proxy
      • Reverse Proxy
      • Fail2ban
      • Docker containers on their own networks
      H This user is from outside of this forum
      H This user is from outside of this forum
      [email protected]
      wrote on last edited by
      #30

      One thing I do is instead of having an open SSH port, I have an OpenVPN server that I’ll connect to, then SSH to the host from within the network. Then, if someone hacks into the network, they still won’t have SSH access.

      C O 2 Replies Last reply
      0
      • O [email protected]

        Inspired by this comment to try to learn what I'm missing.

        • Cloudflare proxy
        • Reverse Proxy
        • Fail2ban
        • Docker containers on their own networks
        S This user is from outside of this forum
        S This user is from outside of this forum
        [email protected]
        wrote on last edited by
        #31

        I put up a sign that says, "No hackers allowed plz"

        O 1 Reply Last reply
        0
        • H [email protected]

          One thing I do is instead of having an open SSH port, I have an OpenVPN server that I’ll connect to, then SSH to the host from within the network. Then, if someone hacks into the network, they still won’t have SSH access.

          C This user is from outside of this forum
          C This user is from outside of this forum
          [email protected]
          wrote on last edited by
          #32

          I do the same, but with Wireguard instead of OpenVPN. The performance is much better in my experience and it sucks less battery life.

          O 1 Reply Last reply
          0
          • O [email protected]

            Inspired by this comment to try to learn what I'm missing.

            • Cloudflare proxy
            • Reverse Proxy
            • Fail2ban
            • Docker containers on their own networks
            C This user is from outside of this forum
            C This user is from outside of this forum
            [email protected]
            wrote on last edited by
            #33

            Some I haven't yet found in this thread:

            • rootless podman
            • container port mapping to localhost (e.g. 127.0.0.1:8080:8080)
            • systemd services with many of its sandboxing features (PrivateTmp, ...)
            ikidd@lemmy.worldI O 2 Replies Last reply
            0
            • O [email protected]

              Inspired by this comment to try to learn what I'm missing.

              • Cloudflare proxy
              • Reverse Proxy
              • Fail2ban
              • Docker containers on their own networks
              Q This user is from outside of this forum
              Q This user is from outside of this forum
              [email protected]
              wrote on last edited by
              #34

              Fail2ban config can get fairly involved in my experience. I'm probably not doing it the right way, as I wrote a bunch of web server ban rules --- anyone trying to access wpadmin gets banned, for instance (I don't use WordPress, and if I did, it wouldn't be accessible from my public facing reverse proxy).

              I just skimmed my nginx logs and looked for anything funky and put that in a ban rule, basically.

              1 Reply Last reply
              0
              • S [email protected]

                I put up a sign that says, "No hackers allowed plz"

                O This user is from outside of this forum
                O This user is from outside of this forum
                [email protected]
                wrote on last edited by
                #35

                How has that been going?

                ikidd@lemmy.worldI 1 Reply Last reply
                0
                • O [email protected]

                  How has that been going?

                  ikidd@lemmy.worldI This user is from outside of this forum
                  ikidd@lemmy.worldI This user is from outside of this forum
                  [email protected]
                  wrote on last edited by
                  #36

                  "All your containers are belong to us."

                  1 Reply Last reply
                  0
                  • C [email protected]

                    Some I haven't yet found in this thread:

                    • rootless podman
                    • container port mapping to localhost (e.g. 127.0.0.1:8080:8080)
                    • systemd services with many of its sandboxing features (PrivateTmp, ...)
                    ikidd@lemmy.worldI This user is from outside of this forum
                    ikidd@lemmy.worldI This user is from outside of this forum
                    [email protected]
                    wrote on last edited by
                    #37

                    I assume #2 is just to keep containers/stacks able to talk to each other without piercing the firewall for ports that aren't to be exposed to the outside? It wouldn't prevent anything if one of the containers on that host were compromised, afaik.

                    mangopenguin@lemmy.blahaj.zoneM C 2 Replies Last reply
                    0
                    • akatsukilevi@lemmy.worldA [email protected]

                      Disable password authentication on SSH

                      Enable firewall and block all ports you're not using(most firewalls do this by default)

                      Switch to a LTS kernel(not security related, but it keeps things going smooth... Technically it is safer since it gets updated less often so it is a bit more battle tested? Never investigated whenever a LTS kernel is safer than a standard one)

                      Use Caddy to proxy to services instead of directly exposing them out

                      HTTPS for web stuff(Caddy does it automatically)

                      ? Offline
                      ? Offline
                      Guest
                      wrote on last edited by
                      #38

                      Caddy or any other (reputable) reverse proxy. I think Nginx Proxy Manager would be best for beginner thanks to GUI.

                      1 Reply Last reply
                      0
                      • shimitar@downonthestreet.euS [email protected]

                        This, but I prefer nginx.

                        And no real need for tailscale or cloudflare. If you do not like to depend on a third party service, either port forward and ddns or an external vps+wire guard if you have gcnat

                        ? Offline
                        ? Offline
                        Guest
                        wrote on last edited by
                        #39

                        This is a valid solution but honestly how is using VPS not depending on third party?

                        shimitar@downonthestreet.euS 1 Reply Last reply
                        0
                        • O [email protected]

                          Inspired by this comment to try to learn what I'm missing.

                          • Cloudflare proxy
                          • Reverse Proxy
                          • Fail2ban
                          • Docker containers on their own networks
                          mangopenguin@lemmy.blahaj.zoneM This user is from outside of this forum
                          mangopenguin@lemmy.blahaj.zoneM This user is from outside of this forum
                          [email protected]
                          wrote on last edited by
                          #40

                          They aren't on the internet mainly.

                          1 Reply Last reply
                          0
                          • ikidd@lemmy.worldI [email protected]

                            I assume #2 is just to keep containers/stacks able to talk to each other without piercing the firewall for ports that aren't to be exposed to the outside? It wouldn't prevent anything if one of the containers on that host were compromised, afaik.

                            mangopenguin@lemmy.blahaj.zoneM This user is from outside of this forum
                            mangopenguin@lemmy.blahaj.zoneM This user is from outside of this forum
                            [email protected]
                            wrote on last edited by
                            #41

                            Containers can talk to each other without any ports exposed at all, they just need to be added to the same docker network.

                            ikidd@lemmy.worldI 1 Reply Last reply
                            0
                            • O [email protected]

                              Inspired by this comment to try to learn what I'm missing.

                              • Cloudflare proxy
                              • Reverse Proxy
                              • Fail2ban
                              • Docker containers on their own networks
                              oderus@lemmy.worldO This user is from outside of this forum
                              oderus@lemmy.worldO This user is from outside of this forum
                              [email protected]
                              wrote on last edited by
                              #42

                              NPM, Nginx

                              If I need remote access, I just log into NPM and I have certain URL's created for Plex, or Sonarr, Radarr etc. No issues so far.

                              1 Reply Last reply
                              0
                              • ikidd@lemmy.worldI [email protected]

                                I assume #2 is just to keep containers/stacks able to talk to each other without piercing the firewall for ports that aren't to be exposed to the outside? It wouldn't prevent anything if one of the containers on that host were compromised, afaik.

                                C This user is from outside of this forum
                                C This user is from outside of this forum
                                [email protected]
                                wrote on last edited by
                                #43

                                It's mostly to allow the reverse proxy on localhost to connect to the container/service, while blocking all other hosts/IPs.

                                This is especially important when using docker as it messes with iptables and can circumvent firewall like e.g. ufw.

                                You're right that it doesn't increase security on case of a compromised container. It's just about outside connections.

                                ikidd@lemmy.worldI 1 Reply Last reply
                                0
                                • ? Guest

                                  This is a valid solution but honestly how is using VPS not depending on third party?

                                  shimitar@downonthestreet.euS This user is from outside of this forum
                                  shimitar@downonthestreet.euS This user is from outside of this forum
                                  [email protected]
                                  wrote on last edited by
                                  #44

                                  It is, but you are free to switch at any time provider, there is no technological lock in like with cloudflare or tailscale (i know there is a free self hostable version, not talking about that).

                                  So just rent a new one and switch your wireguard there.

                                  1 Reply Last reply
                                  0
                                  • mangopenguin@lemmy.blahaj.zoneM [email protected]

                                    Containers can talk to each other without any ports exposed at all, they just need to be added to the same docker network.

                                    ikidd@lemmy.worldI This user is from outside of this forum
                                    ikidd@lemmy.worldI This user is from outside of this forum
                                    [email protected]
                                    wrote on last edited by
                                    #45

                                    I was getting more at stacks on a host talking, ie: you have a postgres stack with PG and Pgadmin, but want to use it with other stacks or k8s swarm, without exposing the pg port outside the machine.

                                    mangopenguin@lemmy.blahaj.zoneM 1 Reply Last reply
                                    0
                                    • C [email protected]

                                      It's mostly to allow the reverse proxy on localhost to connect to the container/service, while blocking all other hosts/IPs.

                                      This is especially important when using docker as it messes with iptables and can circumvent firewall like e.g. ufw.

                                      You're right that it doesn't increase security on case of a compromised container. It's just about outside connections.

                                      ikidd@lemmy.worldI This user is from outside of this forum
                                      ikidd@lemmy.worldI This user is from outside of this forum
                                      [email protected]
                                      wrote on last edited by
                                      #46

                                      OK, yah, that's what I was getting at.

                                      1 Reply Last reply
                                      0
                                      • ikidd@lemmy.worldI [email protected]

                                        I was getting more at stacks on a host talking, ie: you have a postgres stack with PG and Pgadmin, but want to use it with other stacks or k8s swarm, without exposing the pg port outside the machine.

                                        mangopenguin@lemmy.blahaj.zoneM This user is from outside of this forum
                                        mangopenguin@lemmy.blahaj.zoneM This user is from outside of this forum
                                        [email protected]
                                        wrote on last edited by
                                        #47

                                        You can do that by joining the containers to the same docker network, you don't need to expose ports even to localhost.

                                        ikidd@lemmy.worldI 1 Reply Last reply
                                        0
                                        • mangopenguin@lemmy.blahaj.zoneM [email protected]

                                          You can do that by joining the containers to the same docker network, you don't need to expose ports even to localhost.

                                          ikidd@lemmy.worldI This user is from outside of this forum
                                          ikidd@lemmy.worldI This user is from outside of this forum
                                          [email protected]
                                          wrote on last edited by
                                          #48

                                          I mustn't be communicating well, but that's fine.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups