Handling Large Number of Dynamic Hosts in Custom Module Subrequests
Maxim Dounin
mdounin at mdounin.ru
Tue Sep 27 12:40:51 UTC 2016
Hello!
On Mon, Sep 26, 2016 at 06:09:07PM +0000, Cloud Gate wrote:
[...]
> The first alternative approach we've come up with is to set an
> HTTP header in the subrequest containing the target URL
> (x_our_proxy_url=http://host1.domain.foo/...), target the
> subrequest at a static /ourproxy location, and in nginx.conf
> pass the URL from the header to proxy_pass:
>
> location /ourproxy {
> proxy_pass $http_x_our_proxy_url;
> }
>
> While this works, it seems somewhat ad-hoc, and we're wondering
> if there are better options for a subrequest to target arbitrary
> hosts.
> module.
In general, using proxy_pass with a variable is correct. Though
instead of abusing HTTP headers (in general, this is not something
nginx allows, and you are likely doing it wrong) I would recommend
using part of URI instead, or just providing appropriate variable
from your module.
--
Maxim Dounin
http://nginx.org/
More information about the nginx-devel
mailing list