Last active
November 11, 2022 00:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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/" | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"routes": [ | |
{ | |
"match": { | |
"destination": "!127.0.0.1", | |
"headers": { | |
"User-Agent": "Mozilla/5.0*" | |
}, | |
"host": "*.example.com" | |
} | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"routes": [ | |
{ | |
"match": { | |
"host": "v1.example.com" | |
}, | |
"action": { | |
"proxy": "http://127.0.0.1:8000" | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a discussion of these files, see NGINX Unit 1.13.0 and 1.14.0 Introduce Reverse Proxying and Address-Based Routing