Skip to content

Example of nginx routing to different hosts based on the presence or absence of an HTTP cookie.

Notifications You must be signed in to change notification settings

tonymke/nginx_cookie_routing_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nginx_cookie_routing_example

Here we show an example of how nginx can route to different hosts based on the presence or absence of an HTTP cookie.

Using Docker Compose, we start two web servers, "static1" and "static2". They each serve a simple html file identifying themselves.

We then start an nginx acting as a reverse proxy - with the nginx configuration defined in reverse_proxy.conf.

You can validate behavior with curl:

# no cookie set
curl http://localhost:8080
<h1>static_1</h1>
# cookie set
curl --cookie MAGICCOOKIE=any_value http://localhost:8080
<h1>static_2</h1>

About

Example of nginx routing to different hosts based on the presence or absence of an HTTP cookie.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages