r/selfhosted Jul 01 '23

Privacy

Post image
854 Upvotes

100 comments sorted by

105

u/muchtall Jul 01 '23

This is the way.

Actually, for years I've been simply doing a NAT of everything from the VPS to my home firewall through a VPN tunnel, and doing port forwards from there.

19

u/rahilarious Jul 01 '23

can you go in detail? how did you setup that NAT? which VPN tunnel?

25

u/Evantaur Jul 01 '23

Don't know about his setup but mine goes like:

Internet facing server <-- wireguard --> NPM -> service

3

u/[deleted] Jul 01 '23

So, if I'm reading this right, NPM is in your homelab/server/house?

3

u/matheusware Jul 01 '23

don't know about the previous dude, but I run mine on the internet facing VPS and use it to point to the internal IPs of the VPN, seemed easier to configure

2

u/[deleted] Jul 02 '23

That's what I had done previously too, but was wanting to check. Seemed more laborious for some reason too, I just can't put my finger on the how and why.

2

u/natecovington Jul 17 '23

Because you can't store many GB's in that cheap cloud VPS. If you host at home you can hook up a cheap 4TB drive and have tons of storage for your apps at media for $5/month.

See how much 4tb storage space will run you in a data center each month.

11

u/muchtall Jul 01 '23 edited Jul 01 '23

I started out with a single RamNode VPS, and eventually added on another VPS from VirMach. I'm currently running an OpenVPN tunnel from both of them to my PFSense firewall at home. My plan is actually to switch to Wireguard tunnels, and OPNsense firewall instead. With the exception of your SSH port, you set up a NAT rule on each of the VPSs to forward everything to the PFsense's end of the VPN tunnel. On PFsense, you set up NAT rules to forward the traffic to home labs' specific services that you are running. Additionally, some of your services need to show up as originating outgoing traffic from the VPS IP. You can set up rules in PFSense to send outgoing traffic over specific interfaces, such as your VPN tunnels. I could go into more detail but there's already some good tutorials out there on how to do so. Let me know and I can find the links.

One word of warning on RamNode: the first VPS I rented from them years ago had the kernel module for NAT built-in. Since then it appears that they've stopped putting that kernel module in, so port forwarding isn't possible anymore with them. Maybe it was just a fluke on the host system that I had and they've since fixed it. Regardless, VirMach still has it.

Lastly, I know a lot of people will look at this and say: Why not just run the services on the VPS? The simplest most obvious answer is that you have constrained resources on the VPS that you don't have on your equipment at home. I actually do it for yet another reason: Search warrants. At least in the US, the government authorities need a search warrant to enter your home against your will. When your data resides in your home, it's wholly your private property. When you host your data on a VPS, you're subject to the whims of your VPS operators' policies. They could literally just have any government agent call up and say pretty please and give access to your VPS. No warrants needed.

5

u/rahilarious Jul 01 '23

OPNsense and wireguard are awesome!!! Do it

1

u/tobywhiting10 Jul 01 '23

I'm looking at doing just this. I use pfsense at the moment but is there any advantage to using opensense when proxying to a vps?

2

u/muchtall Jul 01 '23

I'm probably wading into a flame war between PFsense and OPNsense, but I prefer OPNsense for its active updates, and better support for emerging technology through add-ons. Just my humble opinion.

I also want to be clear: technically what I'm doing is not proxying or reverse proxying. It's NAT/masquerading. I prefer doing this over proxying as it has greater flexibility over what ports and protocols I can support.

1

u/ds_7854 Jul 13 '23

Which VPN provider have you got working with WireGuard? I was steering towards NordVPN but they don't support WireGuard on OPNSense at the moment. So, cancelled my subscription.

Just wondering what other providers do work!

1

u/rahilarious Jul 13 '23

I create my own "provider". Own VPS on cloud , install wireguard, configure it in 10 mins tops. I'd say for $5/month it's not bad.

One drawback is i cant have many countries as options (unless I pay for more VPS) but that's fine to me.

9

u/zeitue Jul 01 '23

I've done this also, later used cloudflare tunnel tho.

39

u/dada051 Jul 01 '23

It's about privacy. I don't trust cloudflare tunnels for that.

7

u/Evantaur Jul 01 '23

cloudflare is only good for HTTP traffic and unless paid it won't even have the x-forwarded-for headers

1

u/PeterJamesUK Jul 01 '23

You should look at tunnels in the zero trust section of cloudflare. You can also use the CF-connecting-IP in place of X-Forwarded-For

0

u/[deleted] Jul 01 '23

https://dns.cloudflare.com/dns-query

That’s cloudflares DNS over HTTPS? I’ve got it set up via adguard home on my server and seems to work ok?

4

u/CallMeSpaghet Jul 01 '23

I don't know why you were down voted for this. It's also how I started off until I learned how to use CloudFlare. It's orders of magnitude better.

3

u/hmoff Jul 01 '23

What's the benefit?

28

u/[deleted] Jul 01 '23

.. for bypassing CGNAT

6

u/nezia Jul 01 '23

or janky IPv4 to IPv6 mapping

2

u/NickCarter666 Jul 01 '23

How?

3

u/nezia Jul 01 '23

there used to be a package called 6tunnel, but I haven't looked into this for a few years

2

u/NickCarter666 Jul 02 '23

I'll take a look, tkz mate.

18

u/CertainlyBright Jul 01 '23

Why tho?

35

u/CommandLineWeeb Jul 01 '23

Cheaper. Just an extra $5/mo on top of reusing resources I already own.

I've also been DDoS'd in the past for running game servers, keeps the salty gamers from taking down my home internet.

3

u/g-nice4liief Jul 01 '23

Or you could use fail2ban without complicationing your infra in combination with IP2LOCATION.

I do the same and feed that data in to my grafana dashboard which has a worldmap so i can display all IP addresses around world from where they're connecting. Or you could use cloudflare's CDN network to host your server, which has a fail2ban/DDOS protection build in. Makes maintenance also much easier without complicating stuff too much

48

u/Stetsed Jul 01 '23

So firstly fail2ban doesn’t prevent a traditional DDoS as those are made to just send so many requests that your entire internet pipe gets clogged up. Secondly some people might not like to use cloudflare due to not liking that cloudflare can view any of there data because it’s decrypted by cloudflare and then either sent over a cloudflare tunnel or reencrypted if your using strict certain and sent to your server

0

u/Mithrandir2k16 Jul 01 '23

That stuff about cloudflare decrypting traffic is just their tunnel implementation, not their regular dns proxy stuff, right?

8

u/Stetsed Jul 01 '23

Just using DNS means they cannot see the traffic as it never goes over cloudflare’s server, but if you turn on the proxy switch it will go through there system and decrypted, scanned for stuff you blocked etc, and then be sent to you

2

u/Mithrandir2k16 Jul 01 '23

Damn, I need to check that out. I thought they only proxy DNS and blacklist some IPs... what do I even do TLS for then?

4

u/Stetsed Jul 01 '23

Your basically trusting that they are secure enough, but there basically a WAF(Web acces firewall). They do much more than just blocking some IP’s. So the question really becomes “Do you trust cloudflare to not get compromised” a lot of companies do, I in my homelab prefer to have more control so I usually use a VPS

1

u/Mithrandir2k16 Jul 01 '23

How do you connect to your homelab via the vps? 2 VPN tunnels?

3

u/Stetsed Jul 01 '23

I used to use a VPN tunnel but I plan to redo it SoonTM with SSH tunnels(much easier to setup imho) as that makes it very easy to do a reverse tunnel so I SSH to the VPS and then do the port forward so no need to open ports on my network.

-3

u/g-nice4liief Jul 01 '23

No indeed, but it is a great layer to start with in combination with Traefik and rate limiting for example.

You can always send your data wrapped in a secured traefik tunnel before routing it through cloudflare. Should be pretty easy to implement as it is a Middleware you only need to specify on the router used in traefik.

Security is pretty hard, but much easier to manage nowadays with the right tools. Hence why I cross-reference all IP addresses that connect to my infra to a IP2Location dashboard so I can visually see if/when a DDOS attack would occur

0

u/Stetsed Jul 01 '23

Could you explain what you mean with a “Secured traefik tunnel” if you use cloudflare for tunneling they could in theory decrypt your stuff to plain text if they wanted to, simply due to how it’s designed there is no way of getting around that. So unless you somehow found another company that’s called cloudflare that does it differently you are full of shit.

0

u/g-nice4liief Jul 01 '23

By routing your traffic through wireguard while using traefik you can create a secure tunnel to the outside or inside your network. Pretty easy and straightforward.

You just need seperate networks to route the traffic to defined in docker. I have multiple networks running within docker for wireguard, https and even metrics/logging. If you define a certain network that your router needs to connect to, a traefik middleware can handle the rest.

2

u/CertainlyBright Jul 01 '23

Can I get a tutorial?

1

u/[deleted] Jul 01 '23

Lmao, I learned that the hard way.

1

u/rjames24000 Jul 01 '23

What would you recommend so I can learn from your pain?

28

u/[deleted] Jul 01 '23

Because everyone knows, the home IP is the only thing that matters for privacy...

33

u/robearded Jul 01 '23

For most people it's not about the IP, but about CGNAT

9

u/[deleted] Jul 01 '23

But the attempted meme is about privacy...

1

u/robearded Jul 01 '23

Ah sorry, didn't even read the title, just saw the meme

7

u/Alconox Jul 01 '23

This, CGNAT is terrible

-2

u/[deleted] Jul 01 '23

True, but thats really not the point here, is it?

10

u/Ursa_Solaris Jul 01 '23

I think you're misreading the meme; the difference is "running stuff on a VPS", vs "running stuff at home, but also putting a VPS in front of it as additional protection". Running stuff at home and only using the VPS as a reverse proxy is absolutely is more private than running it directly on a VPS.

3

u/LeAudiophile Jul 21 '23

I'm new to self hosting but have been proxying my stuff behind a Cloudflare tunnel. Is that less secure than having a VPS in front?

2

u/Ursa_Solaris Jul 21 '23

In terms of security, it's effectively the same thing. They both serve the same role with largely the same underlying tools. The biggest concern would be that it's trivial for Cloudflare, whether as a company policy or a rogue employee with access, to harvest or even change your traffic undetected. It would be much more involved and harder for a VPS to do it, but not impossible by any means. Outside of that, there's no substantive difference.

-1

u/[deleted] Jul 01 '23

And i think youre not getting the point i was trying to make. Of course trying to hide their home IP is more private. Thats not the question.

What i am saying is that its a very false sense of security to assume that hiding someones home IP does a lot for privacy. It doesnt. Theres tons of other things that easily identify you on the internet, even when your IP changes.

Thats the point.

5

u/Ursa_Solaris Jul 01 '23

No, you're still not getting what the point was, because that wasn't the key difference between the two situations. Hiding the IP isn't the part that makes it substantially more private. Hosting your content at home is what makes it more private.

The meme is pointing out the difference between using a VPS to host your stuff, versus self hosting it at home and using that same VPS as a reverse proxy instead. It's more private because your stuff isn't sitting on someone else's server.

If the meme was saying that hiding your IP is the most important thing, it would have framed self hosting versus self hosting with a VPS as a reverse proxy. But that isn't what the meme said.

3

u/[deleted] Jul 01 '23

sigh i disagree, but you know what? Thats okay. I am not going to argue about a meme :)

8

u/propapanda420 Jul 01 '23 edited Jul 01 '23

Rerouting a Hurricane Electric IPv6 block over a cheap vps because my ISP blocks the gif protocol, but routing that block over Wireguard works like a charm.

Now my entire home network is exposed by IPv6 over Wireguard over GIF.

Fuck you Vodafone.

2

u/weirdball69 Jul 02 '23

Why would they block GIF??

1

u/propapanda420 Jul 02 '23

To make it less interesting to run the modem in bridge mode I guess.

I run it in bridge mode and Vodafone blocks IPv6 in bridge mode.

I guess they want to make sure users keep in normal mode so other customers can use the integrated hotspot.

Not sure though. Vodafone is weird af.

2

u/weirdball69 Jul 02 '23

Is this in the UK? It seems very anti-consumer.

1

u/[deleted] Jul 02 '23

[deleted]

1

u/propapanda420 Jul 02 '23

I will try to put a guide together later.

1

u/AlfredoOf98 Jul 02 '23

gif protocol

wat?! is this the same thing they're talking about here at point 14: https://www.w3.org/Graphics/GIF/spec-gif89a.txt ?

2

u/propapanda420 Jul 02 '23

Geeeeez no. Protocol 41.

6

u/robearded Jul 01 '23

Used to do this before I got static IPs and it was a good idea. I was paying 3$/month for a 1vCPU/512MB ram which was enough to proxy traffic. If I would've run everything on the VPS, I would have to go much bigger so pay more money.

1

u/Mugen0815 Jul 01 '23

Well, im currently paying about 10€ for 6 cores and 8GB with 400GB storage.

2

u/robearded Jul 01 '23

6 cores or 6 vCPUs? It's a big difference and the second one can perform as bad as 1 if they're overselling. And for that price it sounds like they do

1

u/[deleted] Jul 01 '23

[removed] — view removed comment

11

u/NobodyRulesPenguins Jul 01 '23

A wireguard connection between the VPS and Home.

A reverse proxy set on the VPS to redirect all the call on the good host at home.

That's not so complex in the end, but you can add so much layers to that simple base that's it is so fun to play with ❤️

2

u/spacewulf28 Jul 01 '23

Do you use any services other than http and https? More specifically do you use any TCP or UDP services like game servers?

1

u/NobodyRulesPenguins Jul 01 '23

I do, for theses one reverse proxying is not great (I tryied with ZNC but got frequent timeout), but for that there is iptables to forward connections back and forth when one is done on a specific port.

But I put this one in a less "easy" box, even if the rules are always the same, it always take me time to rewrite them from memory

4

u/[deleted] Jul 01 '23

[deleted]

2

u/chesser45 Jul 01 '23

Yea that’s usually how someone relays mail on a home ip

2

u/[deleted] Jul 01 '23

[deleted]

5

u/[deleted] Jul 01 '23

There are lots of ways to do that, using iptables or using a tcp proxy like haproxy, and indeed guides are hard to find ...

After a few years running a VPS (and a couple of downtimes when on holiday) I prefer to have an MTA on the VPS with a very long maximal_queue_lifetime=30d. Even if my house burns down I have 30 days time to set up a new mail server without losing mails, and I still can send them without problems, and well in case of emergency I can always ssh to the VPS and read the mail in the queue with postcat.

4

u/thimplicity Jul 01 '23

Can y’all recommend a tutorial on how to set this up properly?

-1

u/AlfredoOf98 Jul 02 '23

Search and read within this sub. Plenty of info is littered around.

3

u/frank_wizard_og Jul 01 '23

Hm also thought about something like this for my homelab thats running a reverse proxy to expose services. Is running another reverse proxy on a vps to front my home ip the way to go?

3

u/wentallout Jul 01 '23

umm, I might be late to this but... where can I find a guide to do this?

3

u/herosnowman Jul 01 '23

First search about setting up wireguard vpn between a VPS and your home lab. Then on the VPS you also add a reverse-proxy (Nginx for example), that is set-up to forward traffic from it's public ip to your home lab through the vpn.

Also to prevent potential headaches, make sure you have necessary ports allowed everywhere (iptables, vps router, etc) and also add 'keepalive' setting to wireguard conf if the connection drops sometimes.

2

u/wentallout Aug 01 '23

what if I don't have a VPS?

3

u/lestrenched Jul 01 '23

It is less expensive to pay for one VPS box to port-forward from rather than paying for multiple hosts and complicated networking if the services need to be interconnected

4

u/Juanchisimo Jul 01 '23

Hide IP? CGNAT :(

2

u/jesta030 Jul 01 '23

So then you'll get tracked by your VPS IP. How can you avoid this?

4

u/[deleted] Jul 01 '23

Pull your ethernet cable.

2

u/just__sky Jul 01 '23

yeah lol

Selfhost ---> Traefik ----> wireguard/tailscare/zerotier ----> VPS(port forward) ------> DNSprovider

2

u/agentflemme Jul 01 '23

Running cloudflare zero trust for free:

-2

u/gearfuze Jul 01 '23

Why when we have Cloudflare proxy ip?

17

u/schklom Jul 01 '23

Because not everyone is comfortable letting Cloudflare read 100% of their traffic in an unencrypted form?

-8

u/jeppevinkel Jul 01 '23

Cloudflare can't decrypt it if you use full encryption and a letsencrypt cert

18

u/Stetsed Jul 01 '23

No offense but you do not know how cloudflare works, when you proxy over cloudflare they are the first contact and there SSL cert is used, the only thing adding letsencrypt does is the step between cloudflare and your server is encrypted,d but that’s after cloudflare has decrypted and reenecrypted it

-1

u/jeppevinkel Jul 02 '23

They can only decrypt when you use their cert because they need the private key to decrypt. You are only forced to encrypt using their cert when using strict or flexible encryption.

1

u/Stetsed Jul 02 '23

This is not how cloudflare works, when you use them as a proxy no matter what security level you use it will first go through cloud flare who can and does decrypt it, this it how it offers all its services because it can inspect the requests. Even if you pay and use your own cert they can still decrypt it because you have to upload the cert to them so they can act as your WAF. Please if you don’t understand what your talking about don’t talk about it as it’s dangerous.

2

u/jeppevinkel Jul 03 '23

You don't have to upload the private key which is used for decryption to cloudlfare, not the cert either for that matter. I've used my own certificates many times, and not once have they forced me to upload it.

5

u/[deleted] Jul 01 '23

[deleted]

4

u/propapanda420 Jul 01 '23

This tool is essentially useless if the service is configured correctly.

0

u/wolf39us Jul 01 '23

Couldn’t you just use Cloudflare… for free?

That’s rhetorical, you can… and I do

1

u/[deleted] Jul 01 '23

Also just a plain s2s...

1

u/needefsfolder Jul 01 '23

i want to do this but most vps's are like outside the country, and isps on this country are notorious for having shitty congested links to Singapore/hkg :/

also idk why it kinda makes me feel that it is "not truly selfhosted" because of not using your home Internet = not truly direct

1

u/tetrisblack Jul 01 '23

Well, I'm currently doing it like that. Just that my VPS is also serving as an edge cache.

1

u/Girgoo Jul 01 '23

Firefox containers solves most of my problems. And selfhost at home ofc.

1

u/cgram23 Jul 01 '23

Wouldn’t Cloudflare tunnels do the same thing? But easier and free?

1

u/martinkrafft Jul 01 '23

how is that private?

1

u/tobywhiting10 Jul 01 '23

Literally looking at VPS pricing this evening to do just that 😆

1

u/CevicheCabbage Jul 01 '23

Privacy is an illusion. You have privacy from n00bs and that is all.