This commit is contained in:
2026-09-02 02:37:30 +05:30
commit cb821faf54
7 changed files with 147 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/ssl
+26
View File
@@ -0,0 +1,26 @@
NAME := 'cookies'
reload: test
podman exec --tty {{ NAME }} nginx -sreload
test:
podman exec --tty {{ NAME }} nginx -t
sh:
podman exec --tty --interactive {{ NAME }} sh
logs:
podman logs --follow {{ NAME }}
genssl DOMAIN:
mkdir -p ssl
openssl req -x509 -new -keyout ssl/key.pem -out ssl/cert.pem -noenc -days 3 \
-addext 'subjectAltName=DNS:*.{{ DOMAIN }},DNS:{{DOMAIN}}' \
-subj '/CN={{ DOMAIN }}'
container:
podman run \
--detach --tty --rm --replace \
--name cookies \
--publish 8443:443 \
--volume ./conf.d:/etc/nginx/conf.d:ro,z \
--volume ./www:/srv/www:ro,z \
--volume ./ssl:/etc/nginx/ssl:ro,z \
nginx:alpine
+33
View File
@@ -0,0 +1,33 @@
map $host $flavour {
default 'butter';
a.website.com 'chocochip';
b.website.com 'peanutbutter';
}
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
server_name a.website.com b.website.com sub.a.website.com;
root /srv/www;
try_files $uri $uri.html /index.html =200;
add_header 'access-control-allow-origin' '$http_origin';
add_header 'access-control-allow-credentials' 'true';
sub_filter '%COOKIE%' '$cookie_flavour';
location /flavourtest {
return 200 '$host and $flavour\n';
}
location /set {
try_files $uri $uri.html /index.html =200;
add_header set-cookie 'flavour=$flavour; max-age=3600;';
}
location /clear {
try_files $uri $uri.html /index.html =200;
add_header set-cookie 'flavour=$flavour; max-age=0';
}
error_page 497 https://$host:$request_port$request_uri;
}
+14
View File
@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<title>
clear!
</title>
<meta http-equiv="refresh" content="3;url=/">
</head>
<body>
<p>
cleared cookie data. redirecting to / in a bit
</p>
</body>
</html>
+13
View File
@@ -0,0 +1,13 @@
<!doctype html>
<html>
<head>
<title>
hello!
</title>
</head>
<body>
<p>
Here is the cookie flavour: <span id='target'>%COOKIE%</span>
</p>
</body>
</html>
+46
View File
@@ -0,0 +1,46 @@
<!doctype html>
<html>
<head>
<title>
hello!
</title>
<style>
.grid {
display: grid;
width: 60%;
margin: auto;
grid-template-columns: 1fr 3fr;
grid-template-columns: 1fr 3fr;
grid-gap: 3em 1ex;
align-items: center;
}
.grid > header {
grid-column: 1 / span 2;
}
iframe {
height: 3em;
}
</style>
</head>
<body>
<section>
<header>
Here is the cookie flavour: <span id='target'>%COOKIE%</span>
</header>
</section>
<hr>
<section class="grid">
<header>the cookie when i request&hellip;</header>
<code>a.website.com</code>
<iframe src="https://a.website.com:8443/flavour"></iframe>
<code>b.website.com</code>
<iframe src="https://b.website.com:8443/flavour"></iframe>
<code>sub.a.website.com</code>
<iframe src="https://sub.a.website.com:8443/flavour"></iframe>
</section>
</body>
</html>
+14
View File
@@ -0,0 +1,14 @@
<!doctype html>
<html>
<head>
<title>
clear!
</title>
<meta http-equiv="refresh" content="3;url=/">
</head>
<body>
<p>
setting flavour to %COOKIE% and redirecting to /
</p>
</body>
</html>