Skip to content

Instantly share code, notes, and snippets.

@nginx-gists
Last active November 11, 2022 00:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nginx-gists/3841947279722c07e07be2114d3298d1 to your computer and use it in GitHub Desktop.
Save nginx-gists/3841947279722c07e07be2114d3298d1 to your computer and use it in GitHub Desktop.
NGINX Unit 1.13.0 and 1.14.0 Introduce Reverse Proxying and Address-Based Routing
{
"routes": [
{
"match": {
"source": [
"*:8000",
"*:0-65535"
]
},
"action": {
"share": "/single_wildcards_w/ports_or_port_ranges/"
}
},
{
"match": {
"destination": [
"127.0.0.1",
"[2002::]:8000",
"192.168.0.11:8080-8090"
]
},
"action": {
"share": "/single_v4_or_v6_IPs_w/ports_or_port_ranges/"
}
},
{
"match": {
"source": [
"10.0.0.0/8",
"[0ff::/64]:8000",
"10.0.0.0/32:8080-8090"
]
},
"action": {
"share": "/CIDR_v4_or_v6_IP_ranges_w/ports_or_port_ranges/"
}
},
{
"match": {
"destination": [
"10.0.0.0-11.1.0.30",
"[fe08::-feff::]:8000",
"192.168.0.0-192.168.1.101:8080-8090"
]
},
"action": {
"share": "/v4_or_v6_IP_ranges_w/ports_or_port_ranges/"
}
}
]
}
{
"routes": [
{
"match": {
"destination": "!127.0.0.1",
"headers": {
"User-Agent": "Mozilla/5.0*"
},
"host": "*.example.com"
}
}
]
}
{
"listeners": {
"192.168.1.99:8080": {
"pass": "routes/internal",
"tls": {
"certificate": "internal-cert-bundle"
}
},
"203.0.113.1:8080": {
"pass": "routes/external",
"tls": {
"certificate": "external-cert-bundle"
}
}
},
"routes: {
"internal": [
{
"match": {
"cookies": {
"userhash": "2475203514"
},
"uri": "/admin/*"
},
"action": {
"pass": "routes/common"
}
},
{
"match": {
"uri": "!/admin/*"
},
"action": {
"pass": "routes/common"
}
}
],
"external": [
{
"match": {
"source": "203.0.113.51",
"uri": "/admin/*"
},
"action": {
"pass": "routes/common"
}
},
{
"match": {
"source": "!203.0.113.100-203.0.113.255",
"uri": "!/admin/*"
},
"action": {
"pass": "routes/common"
}
}
],
"common": [
{
"match": {
"uri": [
"/js/*",
"/css/*",
"/xml/*"
]
},
"action": {
"share": "/www/static/assets/"
}
},
{
"match": {
"uri": "/admin/*"
},
"action": {
"proxy": "http://192.168.1.100:8080"
}
},
{
"match": {
"destination": "192.168.1.99:8080"
},
"action": {
"proxy": "http://192.168.1.100:8080"
}
},
{
"action": {
"proxy": "http://192.168.1.101:8080"
}
}
]
}
}
{
"routes": [
{
"match": {
"host": "v1.example.com"
},
"action": {
"proxy": "http://127.0.0.1:8000"
}
}
]
}
@nginx-gists
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment