Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

filfreire/cookie-experiment

Repository files navigation

cookie-experiment

nginx experiment to alter set-cookie's domain

Purpose

When using reverse proxy, we might want to change the domain of a set-cookie from one service "mid-flight" before getting the response back.

This is an example implementation on how it can be done using nginx proxy_cookie_domain.

Pre-Setup

  1. Install Docker
  2. Run:
sudo echo "127.0.0.1 cookie-setter.lan" | sudo tee -a /etc/hosts

Build and Run

Run:

# spins up nginx and cookie-setter example service
docker compose up

Test that Domain for Set-Cookie is a different from cookie-setter.lan:

curl -I cookie-setter.lan

## should return
# (...)
Set-Cookie: mycookie=cookie_value; Max-Age=600; Domain=another-domain.lan; Path=/; Expires=Thu, 10 Oct 2024 17:36:02 GMT

About

nginx experiment to alter set-cookie's domain

Resources

License

Stars

Watchers

Forks