can you boot a server if someone tries to connect
from enemenemu@lemm.ee to selfhosted@lemmy.world on 01 Mar 17:07
https://lemm.ee/post/56985475

I’ve got a mini pc which is running always and another one which consumes a lot more power for e.g. jellyfin.

Can I configure it such that the jellyfin server only boots if I connect to it? E.g. I try to connect to jellyfin.y.com and then the server boots because the mini pc tries to connect to it.

I already figured out how to let it sleep automatically as soon as nobody is watching.

Edit: can I add the magic package to the reverse proxy?

#selfhosted

threaded - newest

ShepherdPie@midwest.social on 01 Mar 17:16 next collapse

I think you’ll want to look into Wake On LAN to do this. I can’t give you instructions (tried once unsuccessfully on a Windows installation) but that should be enough to get you started.

enemenemu@lemm.ee on 01 Mar 17:34 collapse

Thanks! I use wake on lan with rtcwake to boot at a certain time. I also found an app via which I can boot the server via wake on lan. But it would be nice if it could wake up just by requesting the service

AbouBenAdhem@lemmy.world on 01 Mar 17:17 next collapse

I believe so—see Wake-on-LAN.

enemenemu@lemm.ee on 01 Mar 17:34 collapse

Thanks! I use wake on lan with rtcwake to boot at a certain time. I also found an app via which I can boot the server via wake on lan. But it would be nice if it could wake up just by requesting the service

sxan@midwest.social on 02 Mar 19:06 collapse

That’s how it works. Wake-on-LAN wakes the computer if the computer receives a network request. Which is the same thing you’re asking for, right?

lemming741@lemmy.world on 14 Mar 18:44 collapse

But it has to be a magic packet, not just any ole request.

Dragonish@lemmy.dbzer0.com on 01 Mar 17:41 next collapse

If you have a reverse proxy running on the mini pc and handling jellyfin.y.com then there is this plugin which will send the WoL packet to the jellyfin server when a request is sent.

github.com/dulli/caddy-wol

enemenemu@lemm.ee on 01 Mar 18:15 next collapse

Thanks!

I use nginxproxymanager, I’ll try to find something similar (I couldn’t find something directly)

Xanza@lemm.ee on 01 Mar 22:59 collapse

I use nginxproxymanager

<img alt="" src="https://i.xno.dev/u/CwFh0r.png">

themachine@lemmy.world on 02 Mar 00:12 next collapse

Whats wrong with NPM?

Xanza@lemm.ee on 02 Mar 00:22 collapse

I mean, use what you want. But caddy is significantly easier to configure. It additionally handles SSL and protects your proxy targets with zero configuration (by default) and supports live configuration reload via the admin interface. It’s tits.

Here’s my config: i.xno.dev/u/fc8N0n.png

Caddy is running a wildcard SSL cert, so once I’ve connected my box to cloudflare, I can setup a subdomain by simply adding it to my caddy config. No additional setup is required. It also works directly with docker, so if you install the lemmy (name of the container) docker container, you can reverse_proxy by simply (assuming they’re on the same docker network):

lemmy.domain.com {
    reverse_proxy lemmy:80
}
themachine@lemmy.world on 02 Mar 02:41 collapse

That sounds more or less to be exactly what I’m doing with NPM currently. I don’t see how it’s easier to configure as all I did was fire up the NPM container, log in, and add my host targets.

NPM also handles SSL both standard http verification as well as DNS auth for wildcards.

keyez@lemmy.world on 03 Mar 00:47 collapse

Caddy can do the same and there is a steep learning curve but I switched about a year ago and only need to touch the config file when I add a host. Can even bring that config to a new server and it will stand up once it starts and picks up the config.

enemenemu@lemm.ee on 02 Mar 09:14 collapse

I’d be happy to switch if I had a good tutorial for caddy. Unfortunately I couldn’t find one.

Xanza@lemm.ee on 02 Mar 09:26 collapse

How complex is your nginx reverse proxy? Caddy is relatively straight forward: i.xno.dev/u/fc8N0n.png

enemenemu@lemm.ee on 02 Mar 11:31 collapse

It doesn’t work. I can’t manage to debug it.

Fedora server. Podman. Selinux. Port 8443. Ipv4.

Xanza@lemm.ee on 02 Mar 18:10 collapse

it doesn’t work

…what exactly doesn’t work. You’re not really giving me enough to help you with.

enemenemu@lemm.ee on 02 Mar 18:12 collapse

Thx for offering your help.

If I would know, I could debug it, but I don’t know where the problem is. I assume the problem is somewhere with podman or selinux

Xanza@lemm.ee on 02 Mar 18:15 collapse

But you gotta understand, there’s no subject to your statement. You just said “it doesn’t work” and I have no idea what you’re doing. Are you installing podman? Are you installing caddy? Are you setting up caddy as a reverse proxy? Are you trying to bring your dog back from the dead? I have no frame of reference.

enemenemu@lemm.ee on 02 Mar 18:22 collapse

Sorry for not having expressed what I did. I wrote a podman compose file, pulled the caddy image, wrote a caddyfile, started it and tried to connect to a service via subdomain.domain.tld .

The caddyfile contains my http and tls ports and the domain and ip for the reverse proxy routing according to the docs.

The result is no log entry in caddy and no result in the browser or curl.

Xanza@lemm.ee on 02 Mar 19:52 next collapse

Did you setup DNS to point to your caddy sever?

enemenemu@lemm.ee on 02 Mar 20:28 collapse

Yes, it works with nginxproxymanager. There’s probably something going on with selinux - I may disable it the next time to test the assumption.

Xanza@lemm.ee on 02 Mar 20:34 collapse

Is your caddy container network set to host? Or at least set to a network which is on the same network as your proxied services?

Ensure that nginx is stopped, and if the domain doesn’t work, attempt to direct connect using your servers IP address and the correct port. If you still can’t connect, check your firewall rules.

enemenemu@lemm.ee on 03 Mar 10:28 collapse

Thx, thats not it

lucid@lemmy.dbzer0.com on 02 Mar 20:05 collapse

You’ll probably get better help if you post your config and any logs. Caddy may not log an entry to a file but you can watch the console logs to see everything (podman logs caddy or similar.)

enemenemu@lemm.ee on 02 Mar 20:27 collapse

Thanks. For now, I spend too much time with it. I’ll try some other time again.

enemenemu@lemm.ee on 16 Mar 21:36 collapse

Thanks again! I managed to set up caddy and it works well so far. Now I am stuck at installing (or using xcaddy. I installed go and the package xcaddy but to me the doc lacks one or two steps. Do you know any tutorial covering that? Thanks!

30p87@feddit.org on 01 Mar 18:04 next collapse

Also an option, systemd based, could be to use systemd socket files, which (as far as I understand) opens a dummy socket and starts the matching service as soon as it’s requested.

enemenemu@lemm.ee on 01 Mar 18:18 collapse

I love systemd.

Is this what you suggest? cybso.de/…/how-wake-lan-remote-host-demand-using-…

This sounds like a proxy that sends a magic packet if it can’t reach the service. That sounds great

30p87@feddit.org on 01 Mar 18:46 collapse

Basically yeah, though other solutions may be easier or more integrated. Using systemd sockets is especially useful if you want to start a service on the local server that is always on, with a service that uses a lot of resources in the background without other user interaction

Mubelotix@jlai.lu on 01 Mar 20:25 collapse

I made a tool that can hibernate systemd services when no request get through their associated nginx service. Using it on jellyfin, works great

sugar_in_your_tea@sh.itjust.works on 01 Mar 20:45 collapse

I assume this works like the reverse of socket activation? If so, that’s pretty rad!

That said, that doesn’t really solve OP’s problem, and I’m not exactly sure what it’s solving for you. Jellyfin doesn’t really use any resources when idle, so it’s not going to save on power or anything like that.

That said, you could probably create an interesting service like this. Basically, if the last interesting service shuts down, you shut the whole machine down, and then use WoL to start it back up when someone wants it. Tune it a bit to reduce how often it reboots (i.e. extend life of your disks) and reduce boot times (i.e. don’t mount the RAID until it’s needed), and it could be really cool!

Mubelotix@jlai.lu on 02 Mar 01:07 collapse

Exactly. It’s like socket activation but plugged into nginx. It might or might not fit OP’s use case, as when you have many small services like jellyfin, ram usage starts adding up. Adding automatic shutdown is a great idea

sugar_in_your_tea@sh.itjust.works on 02 Mar 01:49 collapse

I can see that, especially if running on limited hardware. My server has way more RAM than it needs though (16GB), so saving 50MB here and there isn’t very important.