Securing traffic between a proxy and a backend over a VPN. How do you get a certificate for an internal domain?
from early_riser@lemmy.world to selfhosted@lemmy.world on 01 Jan 12:09
https://lemmy.world/post/41002396

Bit of a followup to my previous post. I now have a VPS with nginx working as a reverse proxy to some services on my DMZ. My router (UDM pro) is running a wireguard server and the VPS is acting as a client.

I’ve used Letsencrypt to get certs for the proxy, but the traffic between the proxy and the backend is plain HTTP still. Do I need to worry about securing that traffic considering its behind a VPN? If I should secure it, is there an easier way to do self-signed certs besides spinning up your own certificate authority? Do self-signed certs work between a proxy and a backend, or would one or the other of them throw a fit like a browser does upon encountering a self-signed cert?

I’d rather not have to manage another set of certs just for one service, and I don’t want to involve my internal domain if possible.

#selfhosted

threaded - newest

mhzawadi@lemmy.horwood.cloud on 01 Jan 12:20 next collapse

If your DNS host has an API, you can get any certificate you like for the host.

e.g. a cert for server.example.com

Even though that host doesn’t exist in public DNS

starshipwinepineapple@programming.dev on 01 Jan 17:41 next collapse

This is what i do via acme.sh with the letsencrypt DNS-01 challenge. I have a cron job scheduled to renew/deploy

vividspecter@aussie.zone on 02 Jan 06:19 collapse

You could also get a wildcard cert using dns challenge, and not even expose the subdomains publically.

hummingbird@lemmy.world on 01 Jan 12:23 next collapse

You don’t need a cert authority to self-sign. You can do it once and be good to go.

db_geek@norden.social on 01 Jan 12:25 next collapse

@early_riser @jwildeboer has a blog post about using step-ca for something like this.

https://jan.wildeboer.net/2025/07/letsencrypt-homelab-stepca/

talkingpumpkin@lemmy.world on 01 Jan 12:28 next collapse

is there an easier way to do self-signed certs besides spinning up your own certificate authority?

Letsencrypt works fine, just use a “real” domain and DNS challenge.

Your service will need to be on the “real” domain, but it won’t need to be accessible externally and you won’t need a public DNS entry for it (of course your VPS will still need to be able to resolve the backend’s name).

coolie4@lemmy.world on 01 Jan 12:33 next collapse

What I’ve usually seen is that the VPS does TLS termination and then comms between the VPS and the LAN are sent http, but still secure due to traveling through the VPN. This is the easiest way if you don’t require full e2ee and trust your LAN

NaibofTabr@infosec.pub on 01 Jan 12:58 next collapse

You can just use openssl to generate x509 certificates locally. If you only need to do this for a few local connections, the simplest thing to do is create them manually and then manually place them in the certificate stores for the services that need them. You might get warnings about self-signed certificates/unrecognized CA, but obviously you know why that’s the case.

This method becomes a problem when:

  1. You need to scale - manually transferring certs is fine maybe half a dozen times, after that it gets real tedious and you start to lose track of where they are and why.
  2. You need other people to access your encrypted services - self-signed certs won’t work for public access to an HTTPS website because every visitor will get a warning that you’re signing your own encryption certs, and most will avoid it. For friends and family you might be able to convince them that your personal cert is safe, but you’ll have to have that conversation every time.
  3. You need to implement expiration - the purpose of cert expiration is to mitigate the damage if the cert private key leaks, which happens a lot with big companies that have public-facing infrastructure and bad internal security practices (looking at you, Microsoft). As an individual, it is still worthwhile to update your certs every so often (e.g. every year) if for no other reason than to remind yourself how your SSL infrastructure is connected. It’s up to you whether or not it’s worth the effort to automate the cert distribution.

I’ve used Letsencrypt to get certs for the proxy, but the traffic between the proxy and the backend is plain HTTP still. Do I need to worry about securing that traffic considering its behind a VPN?

In spite of things you may have read, and the marketing of VPN services, a VPN is NOT a security tool. It is a privacy tool, as long as the encryption key for it is private.

I’m not clear on what you mean by “between the proxy and the backend”. Is this referring to the VPS side, or your local network side, or both?

Ultimately the question is, do you trust the other devices/services that might have access to the data before it enters the VPN tunnel? Are you certain that nothing else on the server might be able to read your traffic before it goes into the VPN?

If you’re talking about a rented VPS from a public web host, the answer should be no. You have no idea what else might be running on that server, nor do you have control over the hypervisor or the host system.

hendrik@palaver.p3x.de on 01 Jan 13:44 next collapse

If that traffic is going through an encrypted Wireguard tunnel, I don’t see a reason to encrypt it a second time. Judging by your description, it’s already encrypted on transport between the router and VPS. HTTPS would add nothing there. It will however add encryption within your DMZ, if you expect something nefarious going on within your DMZ.

HelloRoot@lemy.lol on 01 Jan 14:18 next collapse

frp has an option to encrypt the tunnel

brownmustardminion@lemmy.ml on 01 Jan 14:26 next collapse

This is fine unless you have a slightly higher threat model.

Me personally, I dislike the idea that if someone (VPS provider or LE) were to snoop inside my VPS, they would have all of my unencrypted data where TLS ends and wireguard picks it up.

I don’t do anything illegal, but I do have photos, personal files, and deeply personal journals/notes for which I enjoy the comfort of mind when kept private and secure.

My recommendation is always to have your TLS equipped reverse proxy on your own hardware. Then use a VPS as a SSL passthrough proxy that forwards requests to the locally hosted reverse proxy. You can connect the two via wireguard.

This has a few benefits. It keeps encryption end to end. It also allows you to connect to your server via your domain name even in you LAN. You can hijack your domain at the router level DNS menu to reroute to your local reverse proxy. And it keeps the TLS connection.

thelittleblackbird@lemmy.world on 02 Jan 11:50 collapse

Question, how do you deal with the certificates if you have an external vps doing passthroy?

Because that certificate will not match the domain name of the vps and then everything will fail or at least trigger a lot of alerts.

I really fail to see how an internal backend in a different subnet can send the right certificate

nottelling@lemmy.world on 01 Jan 14:28 next collapse

Self signed for this use case is fine. you know and trust both ends of your connection, and no one else needs to know or trust either end of the connection.

Brkdncr@lemmy.world on 01 Jan 14:43 next collapse

Self signed certs are usually created with OpenSSL. Find an example online. If you own a domain create your cert against that name.

The better option is to get your backend also using let’s encrypt and change to https. The whole point of lets encrypt is “encrypt all the things”

You should be able to fix your browser cert error messages by adding the cert to your trusted root store. Easy to do on desktops, mobile devices might be harder to do without an MDM.

stratself@lemdro.id on 01 Jan 15:35 next collapse

As continued from my answer for ypur previous post I suggest you route pure TCP traffic all the way to your backend and terminate TLS (with a Let’s Encrypt cert) there. In fact, I prefer not to mount any certs on the VPS. This does not involve separate certs nor internal domains.

early_riser@lemmy.world on 01 Jan 17:08 collapse

This would involve a stream when using nginx as a reverse proxy, correct?

stratself@lemdro.id on 01 Jan 19:46 next collapse

Yes it involves nginx’s stream directive

[deleted] on 01 Jan 20:04 collapse

.

LodeMike@lemmy.today on 02 Jan 05:32 collapse

For a domain you own, you can use Let’s Encrypt. If it’s a custom TLD (.lan, etc.) then you need to do self-signed. Most systems can install certificates.

xavier666@lemmy.umucat.day on 02 Jan 08:10 collapse

If it’s a custom TLD (.lan, etc.) then you need to do self-signed

Can you share some resources on this?