nginx on Docker

Docker Desktop

Realizing I didn’t really remember my setup for my raspberry pi instance and the fact that I didn’t have a sandbox install, I decided to test it out locally… And since the laptop got repaired, I didn’t have Docker installed anymore. So I installed the latest version: [[Docker Desktop]]@4.12.0. Didn’t bother with a docker.com account, although I should have one. I’m also doing this for purely edutainment purposes so no licensing!

Ran through the built in tutorial. Useful refresher and highly recommended.

Using the default Image:

nginx on Docker 🌐

Most basic install run it with a name of `some-nginx`, pulling the default `nginx` image… doesn’t actually do anything. It’s running, but not listening so you can’t use it.

```console
$ docker run --name some-nginx -d nginx
```

-p 80:80 now maps port 80 to expose it.

```console
$ docker run --name some-nginx -p 80:80 -d nginx
```

Success! Serving up some content at `http://localhost/`

Pasted image 20220906200113

Map custom content

Of course, that’s the default content. So let’s create a ‘content’ directory and serve up our own content – good refresher on volumes.

Their example maps `/some/content` to the doc root for nginx: `/usr/share/nginx/html`

```console
$ docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -d nginx
```

So let’s create a file:

```console
$ mkdir content
$ cd content
$ cat >> index.html
<html>
<head>
<title> Secure BFFs TEst</title>
</head>
<body>
<h1>
Secure BFFs Test
</h1>
Hello wrold!
</html>
^D

$ cd ..
```

This creates an `index.html` file under the `content` directory. Now let’s map it into the index:

```console
$ docker run --name some-nginx -v content:/usr/share/nginx/html:ro -p 80:80 -d nginx 
```

Whoops, what happened? Same output?
Path needs to be full qualified!

```console
$ docker run --name some-nginx -v /Users/jlin/projects/https/content:/usr/share/nginx/html:ro -d -p 80:80 nginx
```

Success!
Pasted image 20220906202847

Conclusion

You now have a local docker instance running a fetched `nginx` instance serving up your own custom content!

Secure Meandering

Well, not really secure.  I did want to post some more things about getting Raspberry PI up and running.  But that ended up being fairly hard to do when you wanted your only Pi up and running.  I did make it pretty useful – mostly a network server and the docker host running this blog.

I recently started using Obsidian and wanted to try to set up my own github repo – but – not over https this time, but over https.  What did that mean?  Secure Meadering! aka https on meander!

Looking into the Google Domains guild to enabling https on your domain took me to Letsencrypt:

If your web host doesn’t offer HTTPS security, you can obtain an SSL/TLS certificate for your domain from a CA. [Let’s Encrypt](https://letsencrypt.org/) is a CA that provides certificates in the interest of creating a safer Internet.

Reading up on some docker configurations like this one from zactyh 📄, I was reminded of ‘good’ containerized architecture. Leave each module as small and focused as possible.  But my wordpress instance was running double duty – handling requests and serving up wordpress.

Current

First meander.mezerkos.com System Diagram.excalidraw

Goal:
nginx meander.mezerkos.com System Diagram.excalidraw

Plan

Proof of Concept

– Play with nginx image to serve content somewhere other than my machine
– Get a cert and serve up content via https
– Proxy content to existing wordpress instance

Dockerize

– Repackage nginx image with my config
– Update docker compose to use new nginx image
– Run image on Raspberry Pi

Cleanup and follow up

– Lock down ports
– set up redirect

Let’s see how all this goes!

Wake Up! Time to Meander

“Wake Up! Time to die!” -Leon(Bladerunner)

Whelp, the site is back up again after a long-ish hiatus. It’s still WordPress, but running on a Docker image running on a Raspberry Pi. ‘Meander’ started out being hosted on 1&1 when I had some side gigs that needed hosting. But when those efforts died down, I moved things over the free tier of AWS. Primarily as a way to get some ‘free’ hosting as well as to get some more belated hands on ‘cloud’ experience. When that ran out, I just let it go.

I was looking for an easy project that had a clear goal and might clear off some cobwebs and get me a little more ‘geek cred’ again. I had been given some grief from my wife to clean up and get rid of some old legacy hardware lying around. But just getting those ancient towers up and running again to clean them out seemed like more effort that I was willing to give. I needed something easier to get me out of my rut. Combined with having to ‘share’ our family laptop(which was also running out of storage space), what was something I could give a few cycles have something to show for it and still be able to make progress on all fronts?

Getting a lightweight ‘server’ running at home seemed like a reasonable thing to try, right? It’s running now, and I could probably call it a success and call it a day. But why have a blog if you’re not going to post a little bit? Besides it’s a good way to reflect every once in a while.