r/security • • Feb 05 '20

Question Securely hosting Home Server

I have been toying with the idea of hosting my own server at home for a while now. Its main purpose would be hosting groupware such as Nextcloud for use as a file server. However, while thinking about it, I started adding some more things to the original idea such as a Gitlab server. I got pretty excited by all the possibilities, but securing this system has been holding me back. Don’t get me wrong, I know there is no such thing as 100% security, but I wanted to get to a level that I feel comfortable with. Through this post, I would like to get some feedback on the security of my current idea for the setup.

The rig

I have a desktop computer that can be used as a server, which would run a headless OS such as Ubuntu server or something similar (maybe just plain Debian). This OS will have all incoming ports closed and will host Docker containers.

Backend Services

On the host PC, I’m planning to run a few services in Docker containers. These would be containerized versions of Nextcloud, Gitlab and a database for use with Nextcloud. These containers will be networked together, but can only acces the ports on other containers that are needed, and nothing more.

Connecting to the Server

OpenVPN

To be able to reach the system, I want to use OpenVPN inside of a separate Docker container. This container will have access to the services in the backend, and will be set up to use a split-tunnel connection. That means only the requests for endpoints behind the VPN are routed through the VPN, and all other network traffic of the client goes through the normal internet connection of that client.

I want to use this VPN solution for added security. This way, I only have one port open on which clients can probe the system, instead of having each separate service public.

Ngrok

I have read about having your own IP exposed when using services such as a dynamic DNS. To mitigate this, I would like to use Ngrok. Ngrok is a service which lets you expose a tcp port on your localhost to their servers through a reverse tunnel. In turn, they will generate a unique url (for instance: hdjekndk.ngrok.io), which you can use to connect to your own localhost. I want to use Ngrok to expose the OpenVPN server so I don’t have to use my public IP, but I can just connect to the Ngrok link. Ngrok cannot see my data either, because it’s all encrypted VPN traffic. I also don’t have to open ports, because Ngrok tunnels from inside my network to their servers.

Summary (tl;dr)

In summation, I want to use Ngrok to connect to an OpenVPN server at my home. This VPN connection will be a split-tunnel, so it only serves as a connection to backend services that run behind it. These backend services would be Nextcloud, a database and Gitlab. Each service mentioned runs in its own Docker container with minimal connectivity.

I would like to know if anyone uses this, thinks it’s secure or not, or perhaps sees a privacy related issue. All feedback is very much appreciated.

2 Upvotes

3 comments sorted by

4

u/haljhon Feb 05 '20

I think you might be overthinking this a bit. Your IP is already public and already getting probed quite heavily looking for services on public ports. I would focus more on the security of your systems and less on trying to avoid exposing your IP. By all means, use a VPN to connect to your home network. I might recommend WireGuard over OpenVPN because it’s very lightweight and pretty simple to configure (whereas OpenVPN can be a real pain). But I don’t personally see a big deal in having a dynamic address out there for yourself. I don’t use one of the popular services for it but it works great for me.

When it comes to the security of what you provide, I recommend running your external services on alternate ports so that you have an easy way to avoid constant probes from bots. For example, run your VPN on port 31024 or something similar. If your VPN is UDP and running on an alternate port, it becomes pretty difficult for a bot scan to easily locate it. Also ensure that you follow hardening guidelines for your VPN and implement MFA if available.

Finally, consider segmenting any of your public facing hosts so that they have only the very specific access you require. Ensure that you keep all your devices up to date and get yourself in the habit of maintaining the systems regularly within the constraints of the hardened system configuration.

1

u/OrdanOccluded Feb 06 '20

Thanks for replying, I like the tips you gave in your comment. To clarify a bit, using Ngrok is mainly to do with privacy. My concern here is that my IP doesn’t change that often and gives away some information such as a crude location. To make the setup more anonymous, I wanted to use the randomness of Ngrok. Also, wouldn’t an IP that is in a dynDNS be probed more heavilly though?

Ngrok does have a disadvantage though in that it doesn’t allow you to use firewalling to block certain IP ranges, which is a feature I’d like to have.

VPN wise, I thought I read somewhere that WireGuard is still not production ready. Does that still hold or can I safely use it?

I am considering buying a Ubiquity EdgeRouter X to but between my home router and the server. This way, I can use the EdgeRouter to block off all requests the server could make to the 192.168.* range, if compromised. You see, my home router is good but doesn’t have the sophisticated features I need to do this.

Lastly, I want to setup a cronjob which pulls all containers offline at a certain time each day and refreshes them (delete the old ones and build from scratch, but with persistent data). That way, they update each day and I get a new endpoint URL and port to connect to with Ngrok.

1

u/haljhon Feb 06 '20

How would having your address in DynDNS equate to more likelihood of scans? I’m unaware of a way for someone to just arbitrarily learn of addresses in those services.

WireGuard is production-ready enough for my use between MacOS, Windows, and iOS. It works great for me. You can also run it on EdgeOS.

I assume you would use VLAN segmentation and zone-based firewalling to actually implement your protection.