home *** CD-ROM | disk | FTP | other *** search
- <HTML><TITLE>Proxy.pi3</TITLE><BODY><PRE>#!Pi3
-
- # ===
- #
- # Top level configuration file
- #
- # ** IMPORTANT **
- # If you do nothing else then do this:
- #
-
- #... ###### Customize server settings
-
- # Skip below to the definition of 'MainVirtualHostInformation', change
- # the settings for Hostname (*Mandatory* redirects will not work without
- # this!) and Administrator (optional).
- #
- # ===
-
- # Include standard IO and server stuff
- include ../Conf/IO.cnf
- include ../Conf/Server.cnf
- include ../Conf/Pi3API.cnf
-
- # ---
- #
- # IO Object for main listening socket.
- #
- # ---
- <Object>
- Name ServerIOObject
- Class TCPIPIOClass
- Type Passive
-
- # A hostname must be specified for the Pi3Web HTTP server. The hostname
- # will be the used by the server to identify itself in URLs generated
- # for redirects and will also be used to lookup the IP address that this
- # server will listen on.
- BindHost localhost
-
- # A TCP port must be specified for this HTTP server. The TCP port
- # is the port that the HTTP will listen for requests on. This is
- # typically 80 for HTTP servers.
- #
- # Note that UNIX operating systems normally require that the server
- # initially run as user 'root' to bind on ports between 0 and 1024
- BindPort 80
-
- # Timeout accepting connections. -1 specifies no timeout.
- AcceptTimeout -1
-
- # Specify timeout for sending data. -1 specifies no timeout.
-
- RecvTimeout 60
-
- # Specify timeout for receiving data. -1 specifies no timeout.
- SendTimeout 45
- PeerIPVariable STRING:RemoteAddr
- PeerHostNameVariable STRING:RemoteHost
- LocalAddressVariable STRING:LocalAddr
-
- # Flags
- #
- # OwnDB - Object adds its own DB, rather than use the parents
- # this is necessary to avoid collision of values placed in
- # the DB between different connection.
- #
- # SetPeerAddress - IP address of remote peer with be put
- # into the specified variable.
- #
- # DNSReverseLookup - Use reverse DNS to get the hostname of the
- # peer and place it in the specified variable.
- #
- # SetLocalAddress - Put local address in the specified variable.
- Flags OwnDB|SetPeerAddress|DNSReverseLookup|SetLocalAddress
-
- # Pointer to file with lockfile name, to avoid collisions on accept
- # with multiple processes
- AcceptLockFile "../Logs/lockfile.txt"
- </Object>
-
- # ---
- #
- # Main virtual host object.
- #
- # ---
- <Object>
- Name MainVirtualHostInformation
- Class VirtualHostClass
-
- # Administrator for the primary virtual host
- Administrator webmaster@localhost
-
- # Hostname that this server uses in redirects.
- HostName localhost
-
- # Port that the server uses in redirects.
- # Specify it only if it is not the standard port for the protocol in
- # use, i.e. 80 for HTTP and 443 for HTTPS
- # ServerPort 80
-
- </Object>
-
- # ---
- #
- # Thread dispatch object
- #
- # This is an instance of MultiThreadedIOServerClass with appropriate
- # parameters
- #
- # ---
- <Object>
- Name ThreadPoolDispatcher
- Class MultiThreadedIOServerClass
-
- # The IOObject is the object that will be used for the listening socket
- # it can be a real IOObject (such as TCP/IP), as test IO object which
- # feeds stub data into the server or a filter IO object which encrpts
- # or logs data passed through it.
- #
- # Example test IO object:
- # IOObject TestIOObject
- #
- # Log IO to file:
- # IOObject <A HREF="/pidocs/Objects/IO.html#SnoopIO">SnoopIO</A> IOObject="ServerIOObject" OutFile="./snoop.dbg"
- #
- IOObject ServerIOObject
-
- # Dispatch accepted IO connection to the HTTPLogicObject
- LogicObject HTTPLogicObject
-
- # Number of threads to use
- MaxThreads 10
-
- # Number of requests to exit after
- ExitAfter 1000
-
- </Object>
-
- # ---
- #
- # Main Pi3 object.
- #
- # This is an instance of the UNIXDaemonClass to fork the server into
- # one monitor process and 'NumberOfProcesses' child processes.
- #
- # The monitor process automatically starts a new child processes whenever
- # a child process exits.
- #
- # ---
- <Object>
- Name Main
- Class UNIXDaemonClass
-
- # Actual class to accept new IO requests and dispatch them
- ServerObject ThreadPoolDispatcher
- PIDFile "../Logs/pid.log"
- RLimitCpu Maximum
-
- # User that child processes will run as. Server must run as root to
- # be able to change to the specified user. A user id number can be
- # specified with #number. Server which start with root privileges should
- # change to a user id with lesser privileges for security reasons.
- # User nobody
-
- # Group that child processes will run as. Server must run as root to
- # be able to change to a different group. A group id number can be
- # specified with #number.
- # Group #-1
-
- # generate a server unique lockfile name and write it into
- # Logs/lockfile.txt
- LockFileName "../Logs/lockfile.txt"
-
- # Message to write just before the server is ready to start accepting
- # connections.
- # default
- Message "Pi3Web HTTP Server Started"
-
- # Specify the number of processes.
-
- NumberOfProcesses 8
-
- </Object>
-
-
-
- # ===
- #
- # Proxy.pi3
- #
- # HTTP Caching proxy server
- #
- # - The caching proxy server requires external processes
- # to cleanup and/or expire items in the cache.
- #
- # ===
-
- #
- # Load library definitions for classes used here.
- #
- include ../Conf/HTTP.cnf
-
- # ---
- #
- # HandleCachingProxy
- #
- # Instance of BasicProxyClass configured to handle requests as an HTTP
- # caching proxy server
- #
- # ---
- <Object>
- Name HandleCachingProxy
- Class BasicProxyClass
-
- # IO object to make proxy requests
- IOObject ProxyIOObject
-
- # for debugging a snoop IO object can be inserted in the IO
- # request/response chain to generate a logfile. Comment out the
- # previous line and uncomment this one.
- # IOObject <A HREF="/pidocs/Objects/IO.html#SnoopIO">SnoopIO</A> IOObject="ProxyIOObject" OutFile="./proxyio.dbg"
-
- # Specifying 'CacheRoot' turns on caching
- CacheRoot "./Cache"
- </Object>
-
- # ---
- #
- # AccessLogger
- #
- # An instance of ExpressionLoggerClass configured to generate an
- # logfile
- #
- # ---
- <Object>
- Name AccessLogger
- Class ExpressionLoggerClass
-
- #
- # Append
- #
- OpenMode "a"
- #
- # Line to log
- Expression "$A $h - [$t] \"$r\" $s $b$M"
- </Object>
-
- # ---
- #
- # CachingProxy
- #
- # Sequence of handlers for HTTP Caching Proxy
- #
- # ---
- <Object>
- Name CachingProxy
- Class FlexibleHandlerClass
- Init <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
- Headers <A HREF="/pidocs/Objects/HTTP.html#ReadRequestHeaders">ReadRequestHeaders</A>
-
- #
- # Middle phases do not apply to a proxy request
- #
- HostMap <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
- Mapping <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
- CheckPath <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
- CheckAuth <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
- CheckAccess <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
- CheckType <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
-
- #
- # Handle the request with the proxy handler the status is 0
- # (request was not previously handled).
- # Otherwise fall through to the error case.
- #
- Handle Condition="&or(&cmp($s,0),&cmp($s,200))" HandleCachingProxy
-
- #
- # If we got here an error occurred.
- Handle <A HREF="/pidocs/Objects/HTTP.html#SendErrorMessage">SendErrorMessage</A> DefaultMessage="Fragment/500-gw.htm"
-
- #
- # Logging, uncomment to write an access log
- # Log AccessLogger File="Logs/access.txt"
-
- Log <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
- </Object>
-
- # ---
- #
- # ProxyIOObject
- #
- # IOObject for communicating with remote HTTP server. This uses
- # the TCP/IP transport.
- #
- # ---
- <Object>
- Name ProxyIOObject
- Class TCPIPIOClass
- Type Active
- RecvTimeout 60
- SendTimeout 60
- </Object>
-
- # ---
- #
- # HTTPLogicObject
- #
- # HTTP Logic object, dispatches requests to all other handlers
- #
- # ---
- <Object>
- Name HTTPLogicObject
- Class HTTPDispatcherClass
- Handlers CachingProxy
- KeepOpen On
- ServerRoot ./../
- ServerStamp Pi3Web/0.9b4
- DefaultHost MainVirtualHostInformation
- ErrorLogFile "Logs/error.txt"
-
- # Specifying a file for DebugLogFile effectively turns on debugging
- # DebugLogFile "Logs/debug.txt"
-
- #
- # The following to directives specify expressions to be logged
- # before and after each handler execution respectively.
- # The expression as given logs process/thread and handler context
- # information indented to the nested handler level.
- #
- # Timing information is also given for performance tuning.
- #
- # This logging information is EXTREMELY verbose. Don't even
- # think about using it in a production server
- #
- DebugBeforeHandler "[$P:$k] &align(,$X)&align(,$X) |--> $T \
- -------- &align($N,12) &align($R,12) $n \"$r\" $s"
- DebugAfterHandler "[$P:$k] &align(,$X)&align(,$X) |<-- $T \
- &align($D,8) &align($N,12) &align($R,12) $n \"$r\" $s"
- </Object>
- </PRE></BODY></HTML>