Perlbal::Manual::ReverseProxy(3pm) | User Contributed Perl Documentation | Perlbal::Manual::ReverseProxy(3pm) |
Perlbal::Manual::ReverseProxy - Configuring Perlbal as a Reverse Proxy
Perlbal 1.78.
How to configure a Perlbal Reverse Proxy service.
Please read Perlbal::Manual::Configuration first for a better explanation on how to configure Perlbal. This document will make much more sense after reading that.
Configuration of Perlbal as a Reverse Proxy is similar to configuration as a Load Balancer.
Check Perlbal::Manual::LoadBalancer under "Using Perlbal as a Load Balancer" for a sample configuration file and for a brief explanation of the differences between a Load Balancer and a Reverse Proxy.
You can set parameters via commands of either forms:
SET <service-name> <param> = <value> SET <param> = <value>
Default is false.
Default is 2.
Default is false.
Default is 100k.
Default is 256k.
Default if 50k.
Default is 0.
Default is 250k.
Default is 5.
Default if false.
Default is 0.
Default is 0.
Default is false.
Default is false.
See the section "Reproxying" in this document for more information.
Default it 0,0.25,0.50,1,1,1,1,1
Default is false.
See Perlbal::Manual::HighPriority for more information.
See Perlbal::Manual::HighPriority for more information.
Default is 30.
A value of 0 means there is no limit and the connection will only be discarded once the backend asks it to be or when Perlbal is sufficiently idle.
Default is 0.
Default is 209715200 (200MB).
Default is false.
Default is false, but setting it to true is highly recommended if Perlbal is the only client to your backends. If not, beware that Perlbal will hog the connections, starving other clients.
Default is 30.
Deprecated.
Default is 0.
See Perlbal::Manual::HighPriority for more information.
A value of 0 disables the high priority queue system entirely.
Default is 0.
See Perlbal::Manual::HighPriority for more information.
Default is 0, which means cache is disabled.
Default is "certs/server-cert.pem".
Default is "ALL:!LOW:!EXP".
Default is "certs/server-key.pem".
Default if false.
Default is "*".
Perlbal by default adds a header to all replies (such as the web_server role). By setting this default to "off", you can prevent Perlbal from identifying itself.
Default is "on".
backend_persist_cache vs. connect_ahead
The "backend_persist_cache" parameter refers to connections kept alive after being used, while "connect_ahead" refers to connections opened in anticipation.
For instance:
SET backend_persist_cache = 2 SET connect_ahead = 1
Let's assume, for simplification purposes, that your service only has one server. Here's an example of what could happen:
No connections open until the very first request comes in (this may change in the future).
This request starts being served on the open connection; Perlbal opens another connection because "connect_ahead"'s value tells it to always open one in anticipation.
(the first request hasn't concluded yet)
The second connection is used, a third one is created so we still have one in anticipation.
The connection is kept open; this means we now have three open connections: two being used and one free (the first and the third one are free).
The connection is killed, as we already have two other open connections (the first and the third), and that's the number set by "backend_persist_cache" for the number of connections to be kept alive.
Reproxying
Perlbal supports the concept of reproxying. Basically, this gives it the ability to ask a backend node for a file and get back a specific header that says "this file is really over there, get it there." Perlbal will then load that file or URL and send it to the user transparently, without them ever knowing that they got reproxied to another location.
Add the following line to your perlbal.conf to enable reproxying on a per service basis ( reproxying is disabled by default in >= 1.38 ):
SET enable_reproxy = true
This can be useful for having URLs that get mapped to files on disk without giving users enough information to map out your directory structure. For example, you can create a file structure such as:
/home/pics/$userid/$pic
Then you can have URLs such as:
http://foo.com/mysite/users/$userid/picture/$pic
When this URL gets passed to the backend web node, it could return a simple response that includes this header:
X-REPROXY-FILE: /home/pics/$userid/$pic
Perlbal will then use asynchronous IO to send the file to the user without slowing down Perlbal at all.
This support also extends to URLs that can be located anywhere Perlbal has access to. It's the same syntax, nearly:
X-REPROXY-URL: http://foo.com:80/resource.html
You can also specify multiple URLs:
X-REPROXY-URL: http://foo.com:80/resource.html http://baz.com:8080/res.htm
Just specify any number of space separated URLs. Perlbal will request them one by one until one returns a response code of 200. At that point Perlbal will proxy the response back to the user just like normal.
Note that the user's headers are NOT passed through to the web server. To the target server, it looks simply like Perlbal is requesting the resource for itself. This behavior may change at some point.
One final note: the server that returns the reproxy header can also return a "X-REPROXY-EXPECTED-SIZE" header. If present, Perlbal will consider a reproxy a failure if the file returned by the target system is of a different size than what the expected size header says. On failure, Perlbal tries the next URI in the list. If it's a file being reproxied, a 404 is returned if the file size is different.
Perlbal::Manual::Configuration, Perlbal::Manual::FailOver, Perlbal::Manual::LoadBalancer, Perlbal::Manual::Management.
2022-06-28 | perl v5.34.0 |