Dynamic proxy_pass hosts
Maxim Dounin
mdounin at mdounin.ru
Thu Oct 22 14:00:12 MSD 2009
Hello!
On Thu, Oct 22, 2009 at 01:17:16PM +0400, Igor Katson wrote:
> In Apache it is possible to dynamically alter the proxy_pass remote
> host, i.e. like this
>
> RewriteRule ^/proxy_everything/(.*)$ http://$1 [P]
>
> So I cant extract the host from the URI, or from the environment
> variable etc.
>
> Is it possible to do the same with nginx?
Yes, proxy_pass supports variables since 0.6.18. Note that you
must have resolver defined in nginx config if possible upstream
hosts include arbitrary hostnames (i.e. not only ip addresses and
names defined via upstream{} blocks).
http://wiki.nginx.org/NginxHttpProxyModule#proxy_pass
http://wiki.nginx.org/NginxHttpCoreModule#resolver
Note that wiki topics are a bit garbled, probably it's a good idea
to consult original docs too (use google translate if you don't
know Russian):
http://sysoev.ru/nginx/docs/http/ngx_http_proxy_module.html#proxy_pass
http://sysoev.ru/nginx/docs/http/ngx_http_core_module.html#resolver
Maxim Dounin
More information about the nginx
mailing list