Nginx in Advance
Some advance usages about Nginx.
Rewrite by GET Params
Assume we are perform the rewite:
FROM | TO |
---|---|
http://domain.com/a?id=abc | http://domain.com/a/b/id/abc |
Here is the rewrite rule
location /a { if($args ~ "^id=(.*)") { set $theid $1; rewrite ^.*$ /a/b/id/$theid last; } }
Config as a Proxy Server
using the following configruation
location / { resolver 8.8.8.8; proxy_pass $scheme://$http_host$uri$is_args$args; }