# comments work

SERVER max_connections = 10000
# + 4 (stdin,out,err,epoll)

# load some plugins
#LOAD stats
#LOAD queues
#LOAD palimg

#SET buffer_size = 250k
#SET min_rate = 2k
#SET min_rate_check = 10s
#SET user = nobody.nogroup

# globally, no more than 20 connections to each reproxy host
#SERVER max_reproxy_connections = 20

# but only 5 connections at a time to 10.1.0.11:7500
#SERVER max_reproxy_connections(10.1.0.11:7500) = 5

# pools are the best way to define what nodes are in a reverse proxy service
CREATE POOL web_proxy_pool

# add some nodes to the pool
POOL ADD web_proxy_pool 10.0.0.1:80
POOL ADD web_proxy_pool 10.0.0.2:80

# remove a node we didn't want (typically this is useful in the management
# console and not the config file)
POOL REMOVE web_proxy_pool 10.0.0.1:80

# the balance method defines how we pick nodes... random just randomly selects
# a node from the pool.  NOTE: if you set nodefile AND set nodes above, the
# nodefile will override the nodes if it exists.  if the nodefile is not found,
# the above nodes will be used.  it is not required that you set a nodefile and
# configure nodes in this file.  one or the other is fine.
SET web_proxy_pool.balance_method = random
SET web_proxy_pool.nodefile = conf/nodelist.dat

# another way of getting node information... not as useful nowadays, as random
# with verify_backend is the best way to go
#SET web_proxy.balance_method = sendstats
#SET web_proxy.sendstats.listen = 10.1.0.255:4446

CREATE SERVICE web_proxy   # word
SET web_proxy.role = reverse_proxy
SET web_proxy.listen = 0.0.0.0:8080

# define our pool.  this can be changed at run time without any interruption
# of service.
SET web_proxy.pool = web_proxy_pool

# Setup some plugins on this service
#SET web_proxy.plugins = stats, queues

# Define an IP block where we know upstream proxies exist.  This allows
# them to set X-Forwarded-For, X-Host, and X-Forwarded-Host headers and
# causes us not to purge them.
SET web_proxy.trusted_upstream_proxies = 10.0.0.0/24

# How many extra backend connections to keep connected in advance
# in anticipation of incoming clients?  2 or 3 should be plenty..
# it's just a buffer.
SET web_proxy.connect_ahead = 2

# When set to some value above 0, and the incoming request has content-length,
# Perlbal will buffer up to this many bytes in memory before requesting a
# backend connection.  This is useful when you know you're going to be getting
# slow uploads and you don't want them tying up the nodes until you have
# enough data.  As soon as this value is reached, no matter how much data
# we're expecting, we will request a backend.
SET web_proxy.buffer_backend_connect = 250000

# persistent backends are connections that will stay open to the backend
# for more than one request.  if you have it enabled, you can then set
# max_backend_uses to determine how many times to use a backend connection
# before we close it ourselves.  0 means use it until the server closes it.
SET web_proxy.persist_backend = on
SET web_proxy.max_backend_uses = 10

# if you want to limit the number of open persistent connections that perlbal
# will maintain, set this.  the default is 2.  if you have more than this
# number of bored backends, perlbal will begin closing them.
SET web_proxy.backend_persist_cache = 2

# often, the operating system kernel will accept a pending connection
# request as soon as the request comes in but before the connection is
# actually being handled by the web server.  with this turned on, perlbal
# will send an OPTIONS request to the backend and wait for it to respond
# before letting any clients use this backend.
SET web_proxy.verify_backend = on

# users with this cookie containing this subset string get to cut in line.
# obviously, the backend application should check that the user's class
# matches their advertised cookie and not give them the page they want
# if they're cutting in line without warrant:
SET web_proxy.high_priority_cookie = fastq
SET web_proxy.high_priority_cookie_contents = 1

# given the above high priority queuing system, sometimes if the high
# priority queue is really busy, the standard queue will suffer from
# resource starvation. the queue relief system helps prevent this. when
# there are queue_relief_size or more connections in the standard queue,
# newly available backends have a queue_relief_chance percent chance of
# taking a request from the standard priority queue instead of the high
# priority queue.  this can be adjusted to work well with your site.  set
# queue_relief_size to 0 to disable the system entirely.
SET web_proxy.queue_relief_size = 2000
SET web_proxy.queue_relief_chance = 30 # 0-100, in percent

# you can define header transformations to be performed on the request
# headers the users sends before they're forwarded on to the backend.
HEADER REMOVE web_proxy Referer    # remove the Referer header
HEADER INSERT web_proxy X-Foo: 1   # and add X-Foo to requests to the backend
HEADER INSERT web_proxy X-Bar: baz # also add X-Bar and set to baz

#SET web_proxy.serve_top_directories = /static/, /doc/server/, 
ENABLE web_proxy

CREATE SERVICE web   # word
#SET web.plugins = stats
SET web.role = web_server
SET web.listen = 0.0.0.0:8081
SET web.docroot = /usr/share/

# if this option is on, users will be prevented with a list of files in
# directories they have navigated to.  CAUTION: listing directories is
# a blocking operation and is not recommended for busy sites.
SET web.dirindexing = 1

# this defaults to index.html; if you navigate straight to a directory then
# perlbal will try to find files with these names in that directory, one at
# a time. if nothing is found, it will fall back to creating a directory
# list (if that's on) or return a 200 and say directory listing disabled
SET web.index_files = index.html, default.htm

# if this is on, the web server will support persistent connections to the
# client requesting the data.
SET web.persist_client = 1

ENABLE web

CREATE SERVICE mgmt
SET mgmt.role = management
SET mgmt.listen = 0.0.0.0:8065
ENABLE mgmt

# create a palimg service that will handle pallette altering GIFs and PNGs
#CREATE SERVICE web_palimg
#SET web_palimg.plugins = stats, palimg
#SET web_palimg.listen = 0.0.0.0:8083
#SET web_palimg.docroot = /usr/share/
# It will search in /usr/share/palimg/ for images.
#ENABLE web_palimg

# and now create an upload service that lets people PUT files to it
#CREATE SERVICE upload
#SET upload.role = web_server
#SET upload.enable_put = yes
#SET upload.max_upload_size = 150000
# Maximum file size of 150,000 bytes.  Set to 0 for no limit.
#SET upload.listen = 0.0.0.0:8084
#SET upload.docroot = /usr/share/upload/
# All files will be put into /usr/share/upload/ as a base.
#ENABLE upload

