Putting Raspberry Pi Online with Caddy and SSH Tunnel
gist.github.com
gist.github.com
Do you have a static IP or a domain that your beacon uses?
I hadn't considered that, but it makes sense. Since ZeroTier is layer 2, I'd expect it to become a leaky abstraction (at least for performance) in certain cases where algorithms are expecting other layer 2 hardware to be essentially directly connected with a wire when in reality they're connected over the internet.
https://news.ycombinator.com/item?id=24436399
I will definitely do a writeup during/before the Christmas break.
I mean, you’re technically correct, but isn’t this kind of like saying that the .local TLD is free of charge? It’s “free” because it’s not a part of the “normal” internet.
Sure you don't get an interesting name but you do get one.
.oarsinsync is probably a better comparison. It’s not explicitly scoped anywhere, and it works nicely in my oarsinsync bubble, much like .onion works nicely in the ToR bubble.
In both cases, you need to connect using some kind of tunnelling protocol to connect into another network.
For me, all my personal machines have TOR installed anyway and I mostly want public address for gluing things together or being able to access things remotely. It's definitely not usable for everything you normally use domain names for (like showing people the menu at a restaurant.)
I will point out that you don't need to do any extra work to access web servers on TOR at least. I think cloudfront (and I know others) run a proxy that lets you access them with just a normal URL via a web browser. Most OSes need no extra configuration for .local.
You run a Tor proxy (bind to 127.0.0.1:9050) on a server on the Internet, and then run a Tor hidden service inside your LAN.
Then, you acquire an .onion domain for the hidden service (running inside LAN), and configure the Tor proxy (running on a server on the Internet) to access the hidden service via the .onion domain (for example, use Nginx to reverse proxy the hidden service).
This should work. However, I imagine it could be quite a bit slower compare to "normal access", and requires extra steps to secure the transport connection between the hidden service and the proxy as you might not want to have everybody on Tor to be able to access that hidden service.
The latency can be painful but it's way better than nothing.
I will say you should probably be careful about running a webserver on TOR. Almost all my machines have a basic web server just for copying static files to windows hosts I don't want to give my password to. People would find these on TOR and then find my resume, I got plenty of emails asking to set up "hidden sites on the dark web for sharing pictures."
The daemon takes very little memory and CPU.
https://github.com/anderspitman/awesome-tunneling.
There are a surprising number of tools that all do essentially the same thing, and it's often hard to tell how they're different from the other 30 options.
Making a really good solution to this problem has been the focus of my free time for the past month since I wrote this comment[0].
The project I'm working on:
* 100% open source and MIT licensed
* Strive for simplicity throughout. Very few dependencies. No config files, and only a single CLI parameter required to run the server.
* Clients can be remote controlled by the server, and each client can open an arbitrary number of tunnels. ie you don't have to start a separate ngrok process for each tunnel. Just set up the client on each machine you want to tunnel out of and forget about it. Everything is controlled through a simple web UI (or REST api).
* Automate as much as possible. Tunnel creation and Let's Encrypt are already working. Eventually you'll be able to add an API token from your DNS provider and that'll be automated as well.
It's not quite ready (launch planned for 31 Oct 2020), but you can check it out here: https://boringproxy.io/
I still miss Serveo because this was easiest tunnel solution that "just works!"
If you just need ad-hoc tunnels on someone else's servers for free, I'm not sure what the leading options are. localhost.run is one.
As i said - I THINK!
Basically I have a vps running traefik and a bunch of self-hosted services with letsencrypt in a docker-compose stack, but I want it to also be able to take an ssh-forwarded https port and use ssl termination to get it a letsencrypt cert and point it to the domain I want. Apparently the way to do this is to use the traefik file provider option, but at this point I've been trying to get that to work for a month and I have no idea why traefik doesn't recognize the port.
Do you have any recommendations for someone looking for this setup? As I said I'm willing to scrap my current setup, but would still like to be able to have it all run in docker-compose and not renew the certs by hand.
If you're using the auto-mapping stuff, then honestly it sounds like getting traefik to work for the SSH port is probably your best bet. Do you need it to dynamically set up new ports, or is it the type of thing you have a static set of tunnels you always want available?
I don't need to dynamically set up the new ports really. I just have a shell script on the server that forwards the ports using ssh forwarding, and those ports probably won't ever change.
Have you done something similar with an alternative tool? It wouldn't break my heart to migrate from traefik to something else, although I do REALLY appreciate how it integrates into docker-compose and how easy it makes letsencrypt cert creation / renewal (I didn't really like the nginx solutions I was seeing for letsencrypt)
In my case some services are not routed to the public internet and only accessible from within my privat wireguard network. E.g my smart home hub. I really like the flexibility to decide whats available for who.
I also have my phone, laptop, etc all on the wireguard VPN, so I can ssh to anything from anywhere. I also have my laptop open to password-based ssh only from my wireguard VPN, so I can ssh (via termux) into my laptop, which has been extremely convenient in addition to being just plain cool. I can't speak highly enough of wireguard!
Why use the stream module vs the normal proxy module you might ask? You can forward TLS connections down to an edge device without needing to have the TLS certs on the cloud server. This is especially useful so I can easily share the VM with other people without having to worry about if they can intercept my network traffic, while still being able to host other things on the machine. This also has the added benefit of allowing me to forward full wildcard subdomains down to the edge device without having to create a new config entry for it each time.
Now, I use (shameless self plug) sish [2] to set this up. It uses SSH, so I get the added benefit of all of the above, but I don't really worry about using an internal network for ingress communication. It's also very easy to share the service with friends/coworkers so they can get the added benefit of it too. I also make use of the loadbalancing feature for test pi clusters when doing distributed testing which is a breeze now.
There are a bunch of these popping up now which I'm happy to see (serveo, remotemoe, even ngrok has a SSH gateway!) so there's a ton of competition here. I definitely recommend checking at least one of them out since they're pretty easy to setup and can be used in a variety of ways!
[1] http://nginx.org/en/docs/stream/ngx_stream_core_module.html [2] https://github.com/antoniomika/sish
If you share a server with your domain name pointing on it, can't just other people on the server use HTTP validation to get a valid certificate for your domain, then do mitm?
I firewall all traffic over port 80, so HTTP validation won't work. I also don't actually share the server with anyone that has access to it, it's moreso so I can provide them a similar setup to what I have with some semblance of security even if they don't have the expertise to do so.
It's nothing you couldn't do yourself, but we host it for you so you don't have to. We host WireGuard servers which assign a stable public IPv4 and IPv6 on your device's WireGuard tunnel interface.
As far as your device is concerned, it's like its tunnel interface is a publicly addressable connection. Because it is! Just with one extra encrypted hop at the end.
Nothing to install besides WireGuard itself. WireGuard's biggest papercut (Dynamic DNS) is solved because we provide you a connection to a server with a static IP.
No promotional emails. No spam. Just a simple service for a specific, niche need.
Hope to post about its launch here soon. (logan@hoppy.network for questions!)
Happy to add hoppy if you think you're a good fit and submit a PR.
A couple questions:
* Do you provide any sort of reverse proxy service, ie HTTPS termination with Let's Encrypt support, similar to OP?
* Do you provide any DNS integration or automation, or purely IPs?
EDIT: Also how would you compare hoppy to Tailscale?
A subdomain (*.hoppy.link) for the tunnelled IP address provided can be created if you send us a support email.
We do not provide any reverse proxy, but it could be a possibility if there is demand.
Tailscale uses the non-routable IP space, and is strictly for private networks, and cannot publish to public networks.
If we were working full time on it, maybe a month? But we're not and the holidays are approaching. I'd expect Q1 2021.
The only drawback is I don't think it would be possible to connect to a peer from something like heroku where you don't have full control over the server..
A VPN is often just too complex to set up, and also requires some hardware in your local network; though often your router will have that already. Off course a Rpi can act as VPN gateway/server.
But solving it by flipping the "servers" around and running the "appserver" in your network then tunneling it to remote seems a really neat hack to avoid going into VPN hell.
I've used similar techniques for doing a wide variety of operational tasks, so it can be worth it to take the time to figure out how to easily set up tunnels and reverse proxies.
Using Linode as a benchmark, a 512 MB VPS is $5/mo but an 8 GB VPS is $40/mo. But an 8 GB Rasberry Pi 4 is well under $100 with peripherals so after three months it will have paid for itself.
This of course assumes:
1. that the cost of powering the Pi is negligible 2. your home internet connection is stable enough and fast enough 3. your apps run as comfortably on the Pi as on VPS
1. I have much better hardware in my house than any VPS can offer at a competitive price. This is particularly important for storage. Object storage like S3 is relatively cheap, but I just want a file system I can slap a static server (or whatever else I want) in front of. If you go for full block storage the price is way higher, and performance still isn't as good as a local SSD.
2. I hope the future of the internet involves more people self hosting over IPv6. I see tunneling solutions as an intermediate step to that world. If we make it easy for people to self host, it might even be able to help drive IPv6 adoption.
I’m not sure people who aren’t network administrators should be putting public IPv6 all over their LAN behind their router, at least not until v6 is more common and routers have better inbound security features for such things (like how NAT functions today for v4).
Every single tutorial on the topic is IPv4-specific and until IPv6 isn't more common, people will not write guides and tutorials with IPv6 in mind. So until the knowledge of proper security on open networks is common enough among home tinkerers, we should not be recommending people just throw everything straight onto the open Internet.
somewhat simplified like this using iptables on linux:
iptables -t nat -A POSTROUTING -o WAN -j MASQUERADE
vs iptables -A FORWARD -i WAN -m state ! --state RELATED,ESTABLISHED -j REJECTThere's nothing wrong in using NAT to increase the cost of attack as a part of a larger defence strategy.
Solutions can always be improved, but it's not always worth doing that.
The only TCP in use is the TCP connection of the SSH connection between hosts.
Beware of TCP over TCP issues[0] when using SSH for tun.
ssh -R80:localhost:80 remote.moe
it should output an URL where your local port 80 is now available
I wonder how a somehow simpler config syntax (Caddyfile) compares to a simpler maintenance system (apt).
To give you an idea about the compatibility differences, it's like the upgrade from Vue.js 2 to Vue.js 3. Some changes to format are necessary for the new architecture. But you can always just run the older version (that's what I do). And swapping to the new one isn't terribly painful if your just using vanilla (for Caddy 1 extensions, which weren't created by the developer himself most of the time, I'm sure Caddy 2 versions will pop up over time).
I haven't found the changes in Caddy's config format to be problematic in the least.
I mean, in 90+% of cases, you just put in your Caddyfile
*host* {
reverse_proxy 0.0.0.0:*port*
}
and you get a fast reverse proxy that just works, with letsencrypt enabled by default to boot, nothing to worry about.However, if you find yourself against a service that requires a slightly more advanced configuration, good luck making sense of their opaque configuration, especially since they now went v2 so everything old is out of the window, so if you search for something, chances are it's no good anymore.
H2O web server seems to be faster than nginx , litespeed and supports http1/http2/http3 . It's config file is yaml file.
For HTTPS, i recommend https://acme.sh . It's very very easy and autorenews certificates using cron job.
This isn't quite what GatewayPorts does. By default, the client can open a tunnel to any ports the user has access to, but those ports can only be connected to from localhost on the server. So even if you don't have a firewall, external IPs can't connect to your tunnel (but your reverse proxy can, if it's running on the same machine). You can use GatewayPorts to allow binding from other IPs. This is useful if you want to tunnel arbitrary TCP traffic, not just HTTP through your reverse proxy.
What next? Well I setup some handy shell functions:
1) copy the latest screenshot into webroot/screenshots/${randstr}.png and copy the url to clipboard. this replaces dropbox's cool screenshot sharing feature. love sharing screenshots with coworkers this way, the files stays with you, you can redact easily.
2) serve static files the same way, if needed too. the magic's all in the shell scripts.
3) explore new open source webapps running on local docker.
Further?
Build a sort of like a devtools backend server, and a mobile app paired to it to do all sorts of cool stuff: run crons, get notifications for events, monitor servers / ssl expiry etc.
Limit's your imagination. But, security is also very important.
I've scoured all config that I could think of, iptables, network adaptors, Wireguard, but can't find the cause. Anyone encounter this or have a place to point me for help?
The key was enabling IP forwarding, and setting the right iptables rules.
Also is your home network's cidr in allowed ips on the vps' wireguard interface?
[1]: https://docs.mysirena.xyz/centos-7/prefilight-configuration/...
`iptables -t raw -I PREROUTING -p udp --dport 51820 -j TRACE` (assuming default 51820 port) and look at dmesg or `journalctl -f`
If that is not being blocked then you can look at `iptables -t raw -I PREROUTING -s <vps' wireguard ip> -j TRACE` and try pinging or reaching a service on your home network and look at dmesg again.
Just don't forget to remove these rules again as they will continue to log.
Beyond that, I'm not sure.
https://linuxconfig.org/how-to-turn-on-off-ip-forwarding-in-...
If you're running Docker, I believe it sets this by default, but try setting this on your VPS. I don't know enough about devops to know if there is an inherit danger to this, so take my advice with a grain of salt, but this worked for me.
I have tried a ssh port forward solution earlier, but the connection fell down, did not always come up after boot and was generally unreliable.
I found wireguard to be much easier to set up and highly reliable. It's in my own opinion not that hard to set up either, there are plenty of guides. The wireguard project docs are also quite good.
WireGuard is a great solution, but I have heard people speak highly of autossh, which I believe may solve this.
It can also turn on my machines via wake on lan. I'm quite happy with the setup since I can leave home anytime for long periods and always know I have access to the "home base".
Tunnel Public Internet Traffic To A Home Linux System via An Intermediary SSH ServerAm I correct that Wireguard and SSH are the more secure options?
I picked OpenSSH purely because it's been around so long and had so much data tunneled through it.
That said, I would still trust WG with my data. I just don't trust it more than a proven SSH implementation, yet.
I'm a little confused as to why you would go through the trouble of running a reverse proxy on a remote server that is fully capable of hosting your web applications and or just setting up a port forwarding rule on your local wifi router to redirect 10080 to 80.
Yes there are privacy reasons but that is not mentioned.
Im guessing the other commentors did not view the OPs git.
You failed to do that twice just in this thread.
For many of us, it's a trust thing.
--
ETA:
Speaking of trust, I just read this FAQ on inlets.dev:
> Does inlets PRO "call home"?
> We trust our users to purchase the correct license for their usage, and in return we make licensing simple with a fixed-term license.
So, a few minutes after mentioning that "it's a trust thing", I came across this very simple, to the point, "yes or no" question ...
... and yet I notice that you|your company) (couldn't|didn't), for whatever reason, actually answer the question.
That, of course, makes me even more distrustful than I was a few minutes ago!