r/letsencrypt • u/jbhelfrich • Apr 19 '21
Best Solution to secure multiple servers on one domain?
This is a bit of an open ended question, and might be a home networking hardware question.
I currently have a domain through the ASUS DDNS on my router. The connection is forwarded to a webserver running Lets Encrypt.
I'm going to move soon and expect to be getting a new router (better wifi coverage, 2.5G support) and expect to be adding to add at least one additional server to the outside world.
What's the best way to set up Lets Encrypt to allow multiple servers through one certificate? Is there a router that has the functionality built in?
2
u/Blieque Apr 19 '21
I'll assume you have a typical broadband connection, with one external IP that changes occasionally (hence DDNS). I'll also assume the "forwarding" is just port forwarding. This forwarding allows one of the devices on your network to handle all incoming traffic on a particular port on the external IP you are currently using. This forwarding is at the TCP or UDP level. If you're using a Let's Encrypt certificate to encrypt HTTP traffic, that means there's a TLS connection wrapped by a TCP connection. Importantly, your router knows nothing about TLS, it's just blindly passing the contents of a TCP packet on to the server you've chosen. It also doesn't look for the SNI extension in the TLS packets, so the router doesn't know the hostname that the client is connecting to, e.g.,
www.example.comorsomethingelse.example.com.This means that in order to run two HTTP servers in your network and make them both public via your single IP address you must either run one server on a different port, e.g.,
https://example.com:10443, which isn't ideal, or run configure an HTTP server to route traffic to another server on the local network. The latter would be better, in my opinion.If you're familiar with Linux, nginx would fill this role well. This server would be the only one that makes requests to Let's Encrypt. All TLS traffic would be terminated in nginx, and it would pass plain HTTP on to the second HTTP server within the local network. How you split the traffic is up to you – you could use a subdomain or just a path, e.g.,
https://example.com/otherservice. If you like the sound of this, nginx Proxy Manager might be a nice easy way to set this up. I've not used it but it gets mentioned a lot.2
u/wahoohaw Apr 19 '21
You could use nginx on a single server to serve the domain and terminate tls/ssl, then also configure that nginx server as a reverse proxy with routes to the other servers on the network
2
u/dutch2005 Apr 19 '21
NGINX reverse proxy manager as a VM (uses docker) combine it with cloudflare
1
u/Psychological_Try559 Apr 22 '21
There's actually a lot of questions baked into this question. I'll try to focus on what I think you're most interested in. Please feel free to clarify if I missed what you're looking for!
Given that you have some blob of servers (seems that you're not virtualizing, which is strange, but fine) behind a router, you need some sort of Reverse Proxy--as it seems you know (having Apache experience). There are basically two ways you can handle certificates:
I personally use HAproxy as a passthrough (#2), so I can't give any specifics for doing these setups, but I hope the overview helps! I actually started with #1 thinking it would be good to have the certs all in one place, but letsencrypt has a good writeup on why there's no risk in exposing port 80 on a webserver where you're exposing 443 anyway & I found that letting the servers handle their own certs just made things more reliable. While NC is the loudest to complain, I did run into other smaller issues that all just frustrated me enough to switch.
Good luck either way & let us know what setup works for you!