2

This question may sound strange or be improperly phrased. I have a nginx web server X that has to request some data from other servers Z. It is possible to have a proxy P that I control, such that X accesses Z through P.

X --> P --> Z

Question: Is it possible to have another proxy Q between P and Z, giving:

X --> P --> Q --> Z

where the proxy Q that is chosen depends on a parameter (say id) that web server X knows of? Maybe the paramter id can be passed from X to P in the headers, and if that is possible, P can use id to query a MySQL database to retrieve the correct proxy details Q and use that as the proxy for this particular connection? If this is possible and ideal, how should this be setup?

Also in this case, are P and Q considered forward proxies or reverse proxies?

Nyxynyx
  • 61,411
  • 155
  • 482
  • 830

1 Answers1

1

Yes, you can do that. Many web sites do that all the time. Look at how webservices work BTW.

It's generally better if P/Q are reverse-proxies than proxies, because reverse-proxies don't modify the request and ensure that you can have any number of such components (including none) between X and Z. So when your application on X works with Z, it will automatically work with P in the middle when it's a reverse-proxy. That's a very important aspect to consider when developing your application !

Now depending on the product used for P, you'll have more or less capabilities. For example, haproxy will be able to match your id in headers, request args, etc... but it will not be able to look it up from a database. I'm fairly sure that you'll find some products which are able to perform such a lookup (whether or not doing so is efficient is another question).

Hoping this helps!

Willy Tarreau
  • 3,384
  • 1
  • 17
  • 11
  • Thats very insightful, thank you Willy. I attempted to use Squid as a forward proxy `P` but its lookup features has to be based around ACL which is severely limiting. Will nginx be suitable as the reverse proxy `P` that can read the id in headers and perform the lookup to determine which `Q` to use? I am currently having difficulty understanding how nginx can communicate with a database and use the returns to decide which proxy `Q` to use. I'm assuming its different from a nginx web server that runs php5-fpm via fastcgi whose php script can lookup the mysql. – Nyxynyx Jan 04 '13 at 22:01