Nginx Server for Blu-Blog
Sun 04 August 2024Now that I've got a hugo build going, my reverse proxy working, and minecraft in a proper docker container, it's time to get either nginx or apache working for serving the blog html! Preferably in a docker container!
I had nginx running already on the Pi, so I just disabled that and I think it's still fine. I should be able to have the hugo server running while also deploying the docker nginx container.
I'm reading an article I found very slowly on the inner workings and a barebones config. I've also written some proto-files; Dockerfile, docker-compose.yaml, and nginx.conf.
Looking up info on the config bits they reference, I landed on a stackoverflow question about the resolver. It looks like I could maybe use this for DNS on the fly for my reverse proxy on the fly.io (oh god the wording) container. Update the DNS info for blog.b-i.net like regular, have resolver at 8.8.8.8 for clownflare or something.
Dockerfile and docker-compose.yaml turned out a lot like the minecraft one from yesterday. The instructions tell you to use an image, which prevents a build from happening, which prevented my config file from being, you know, built. I don't know how that's supposed to work. But I changed image: "docker.io/library/nginx:alpine" to "build ." and got it working to build.
Then, I ran into issues with the debian utils being "addgroup" and "adduser" instead of groupadd and useradd. I'm sure there's a fascinating history behind that particular user experience shitshow. With that fixed, I got an error with user id 1000 existing already inside the docker container somehow. So I changed the Dockerfile to just make the group of ID 1000, then set user to 1000:1000 instead of rhrgrt:rhrgrt. Fixed the blu-blog host dir permissions and...
nginx: [emerg] unexpected "}" in /etc/nginx/nginx.conf:26
literally how? it's paired to an open brace. Codium keeps track of that for me. Googling yields a suggestion that it might be a missing semicolon; a semicolon is definitely missing. Be cool if nginx didn't suck dirt at figuring out what's wrong tho, what the fuck kind of suggestion is that??
Next issue: blu-blog-container | nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (13: Permission denied)
This is almost certainly because nginx isn't running as root anymore. I changed the scope of chown but that just led to more problems each time. So I had to revert the USER 1000:1000 for now, just to get it running. Seems to have worked, at least; I opened a shell to the container and can see the logs and they're owned by rhrgrt. I think the only important part is chowning the logs + volume, so that subsequent edits by root don't ruin things.
2024-08-05 early morning
A rough timeline:
- early afternoon:
I should really get another server soon, so that I can leave my pi for just an access point to avoid breaking anything - 3:34 am, when my laptop's internet goes out:
this must be the laptop's wireless card, and not exactly the thing I was worried about - 4:48 am, discovering Docker's bridge interferes with the raspi access point's eth-wireless bridge:
motherfuuu--
2024-08-07 got me a mediummathbox
I decided to go ahead and do this on a different computer than my wifi access point. Copied everything over to the medium mathbox, got Docker installed, spun up a container, got nginx serving static pages. And, I still have wifi! Hooray, no painful lessons here!
Blu Blog