From 1f9ee3ce9edb962f6a350b9003a01a2ca62d3fb6 Mon Sep 17 00:00:00 2001 From: kevinnls Date: Wed, 2 Sep 2026 14:33:48 +0530 Subject: [PATCH] support docker (+compose) --- README.md | 44 +++++++++++++++++++++++++++++++++++++++----- docker-compose.yml | 10 ++++++++++ 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 docker-compose.yml diff --git a/README.md b/README.md index 6ad83e7..aef3637 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,34 @@ +# what is this? + to play with cookies this serves a nginx server on port 8443 +# how to use? + +## set up dns + > [!CAUTION] -> you want to change your `/etc/hosts` (on \*nix) +> you want to change your `/etc/hosts` (on \*nix; requires root) ``` # /etc/hosts 127.0.0.1 website.com a.website.com b.website.com sub.a.website.com ``` +the nginx config has these domains hardcoded. change them too if you want + +## set up tls + +run `make setup-tls` + +you don't have `make`? well install it. + +you don't have `openssl`? what insane operating system are you on? get openssl too. + + +## change the cookie attributes + to add attributes, modify the file `cookieattr` ``` # cookieattr @@ -17,16 +36,31 @@ set $cookie_attr 'Secure; Domain=a.host.com; HttpOnly;'; ``` note that the `;` at the end is the line terminator for nginx config and is necessary -next, install `just` for your system. take a look at if unsure how +## start the server -get `podman` too while you're at it. you don't have `openssl`? what insane operating system are you on? get openssl too. +### with compose + +```console +$ docker compose up -d +$ docker compose exec cookies nginx -s reload +$ # or create a make/just target to do that +``` + +### with podman ```console -$ just setup-tls $ just container $ # now you mess around with cookieattr $ # you look at https://a.website.com https://b.website.com https://sub.a.website.com $ # you can tell you need to tell your browser you want a taste of danger $ just reload -$ # ^ do that when you make changes to server.conf +$ # ^ do that when you make changes to config +``` + +# what if sth doesn't work? + +might be the `:z` label in the `volumes` in `docker-compose.yml`. remove it. +e.g. +``` +- ./tls:/etc/nginx/tls:ro ``` diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..a092763 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +services: + cookies: + image: nginx:alpine + volumes: + - ./conf.d/:/etc/nginx/conf.d:ro,z + - ./tls:/etc/nginx/tls:ro,z + - ./www:/srv/www:ro,z + publish: + - 8443:443 +