home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 May / Pcwk5b98.iso / WEBSERVE / PI3 / PI3WEB.EXE / Pi3Docs / Examples / Config / Proxy.pi3 < prev    next >
Encoding:
Text File  |  1997-10-31  |  8.9 KB  |  341 lines

  1. <HTML><TITLE>Proxy.pi3</TITLE><BODY><PRE>#!Pi3
  2.  
  3. # ===
  4. #
  5. # Top level configuration file
  6. #
  7. #    ** IMPORTANT **
  8. #    If you do nothing else then do this:
  9. #
  10.  
  11. #... ###### Customize server settings
  12.  
  13. # Skip below to the definition of 'MainVirtualHostInformation', change
  14. # the settings for Hostname (*Mandatory* redirects will not work without
  15. # this!) and Administrator (optional).
  16. #
  17. # ===
  18.  
  19. # Include  standard IO and server stuff
  20. include ../Conf/IO.cnf
  21. include ../Conf/Server.cnf
  22. include ../Conf/Pi3API.cnf
  23.  
  24. # ---
  25. #
  26. # IO Object for main listening socket.
  27. #
  28. # ---
  29. <Object>
  30.     Name ServerIOObject
  31.     Class TCPIPIOClass
  32.     Type Passive
  33.  
  34. # A hostname must be specified for the Pi3Web HTTP server. The hostname
  35. # will be the used by the server to identify itself in URLs generated
  36. # for redirects and will also be used to lookup the IP address that this
  37. # server will listen on.
  38.     BindHost localhost
  39.  
  40. # A TCP port must be specified for this HTTP server. The TCP port
  41. # is the port that the HTTP will listen for requests on. This is
  42. # typically 80 for HTTP servers. 
  43. #
  44. # Note that UNIX operating systems normally require that the server
  45. # initially run as user 'root' to bind on ports between 0 and 1024
  46.     BindPort 80
  47.  
  48. # Timeout accepting connections. -1 specifies no timeout.
  49.     AcceptTimeout -1
  50.  
  51. # Specify timeout for sending data. -1 specifies no timeout. 
  52.  
  53.     RecvTimeout 60
  54.  
  55. # Specify timeout for receiving data. -1 specifies no timeout. 
  56.     SendTimeout 45
  57.     PeerIPVariable STRING:RemoteAddr
  58.     PeerHostNameVariable STRING:RemoteHost
  59.     LocalAddressVariable STRING:LocalAddr
  60.  
  61. # Flags
  62. #
  63. #   OwnDB - Object adds its own DB, rather than use the parents
  64. #               this is necessary to avoid collision of values placed in
  65. #               the DB between different connection. 
  66. #
  67. #   SetPeerAddress - IP address of remote peer with be put
  68. #               into the specified variable.
  69. #
  70. #   DNSReverseLookup - Use reverse DNS to get the hostname of the 
  71. #               peer and place it in the specified variable.
  72. #
  73. #   SetLocalAddress - Put local address in the specified variable.
  74.     Flags OwnDB|SetPeerAddress|DNSReverseLookup|SetLocalAddress
  75.  
  76. # Pointer to file with lockfile name, to avoid collisions on accept
  77. # with multiple processes
  78.     AcceptLockFile  "../Logs/lockfile.txt"
  79. </Object>
  80.  
  81. # ---
  82. #
  83. # Main virtual host object.
  84. #
  85. # ---
  86. <Object>
  87.     Name MainVirtualHostInformation
  88.     Class VirtualHostClass
  89.  
  90. # Administrator for the primary virtual host
  91.     Administrator webmaster@localhost
  92.  
  93. # Hostname that this server uses in redirects.
  94.     HostName localhost
  95.  
  96. # Port that the server uses in redirects.
  97. # Specify it only if it is not the standard port for the protocol in
  98. # use, i.e. 80 for HTTP and 443 for HTTPS
  99. #    ServerPort 80
  100.  
  101. </Object>
  102.  
  103. # ---
  104. #
  105. #    Thread dispatch object
  106. #
  107. #   This is an instance of MultiThreadedIOServerClass with appropriate
  108. #   parameters
  109. #
  110. # ---
  111. <Object>
  112.     Name ThreadPoolDispatcher
  113.     Class MultiThreadedIOServerClass
  114.  
  115. # The IOObject is the object that will be used for the listening socket
  116. # it can be a real IOObject (such as TCP/IP), as test IO object which 
  117. # feeds stub data into the server or a filter IO object which encrpts
  118. # or logs data passed through it.
  119. #
  120. #    Example test IO object:
  121. #     IOObject TestIOObject
  122. #
  123. #    Log IO to file:
  124. #    IOObject <A HREF="/pidocs/Objects/IO.html#SnoopIO">SnoopIO</A> IOObject="ServerIOObject" OutFile="./snoop.dbg"
  125. #
  126.     IOObject ServerIOObject
  127.  
  128. # Dispatch accepted IO connection to the HTTPLogicObject
  129.     LogicObject HTTPLogicObject
  130.  
  131. # Number of threads to use 
  132.     MaxThreads 10
  133.  
  134. # Number of requests to exit after
  135.     ExitAfter 1000
  136.  
  137. </Object>
  138.  
  139. # ---
  140. #
  141. # Main Pi3 object. 
  142. #
  143. # This is an instance of the UNIXDaemonClass to fork the server into
  144. # one monitor process and 'NumberOfProcesses' child processes. 
  145. #
  146. # The monitor process automatically starts a new child processes whenever
  147. # a child process exits.
  148. #
  149. # ---
  150. <Object>
  151.     Name Main
  152.     Class UNIXDaemonClass
  153.  
  154. # Actual class to accept new IO requests and dispatch them
  155.     ServerObject ThreadPoolDispatcher
  156.     PIDFile "../Logs/pid.log"
  157.     RLimitCpu Maximum
  158.  
  159. # User that child processes will run as. Server must run as root to 
  160. # be able to change to the specified user. A user id number can be
  161. # specified with #number. Server which start with root privileges should
  162. # change to a user id with lesser privileges for security reasons.
  163. #   User nobody
  164.  
  165. # Group that child processes will run as. Server must run as root to
  166. # be able to change to a different group. A group id number can be
  167. # specified with #number.
  168. #   Group #-1
  169.  
  170. # generate a server unique lockfile name and write it into
  171. # Logs/lockfile.txt
  172.     LockFileName "../Logs/lockfile.txt"
  173.  
  174. # Message to write just before the server is ready to start accepting
  175. # connections.
  176. # default
  177.     Message "Pi3Web HTTP Server Started"
  178.  
  179. # Specify the number of processes. 
  180.  
  181.     NumberOfProcesses 8
  182.  
  183. </Object>
  184.  
  185.  
  186.  
  187. # ===
  188. #
  189. # Proxy.pi3
  190. #
  191. #    HTTP Caching proxy server
  192. #    
  193. #    - The caching proxy server requires external processes
  194. #    to cleanup and/or expire items in the cache.
  195. #
  196. # ===
  197.  
  198. #
  199. # Load library definitions for classes used here.
  200. #
  201. include ../Conf/HTTP.cnf
  202.  
  203. # ---
  204. # HandleCachingProxy
  205. #
  206. # Instance of BasicProxyClass configured to handle requests as an HTTP
  207. # caching proxy server
  208. #
  209. # ---
  210. <Object>
  211.     Name HandleCachingProxy
  212.     Class BasicProxyClass
  213.     
  214.     # IO object to make proxy requests
  215.     IOObject ProxyIOObject
  216.  
  217.     # for debugging a snoop IO object can be inserted in the IO 
  218.     # request/response chain to generate a logfile. Comment out the
  219.     # previous line and uncomment this one.
  220. #    IOObject <A HREF="/pidocs/Objects/IO.html#SnoopIO">SnoopIO</A> IOObject="ProxyIOObject" OutFile="./proxyio.dbg"
  221.  
  222.     # Specifying 'CacheRoot' turns on caching
  223.     CacheRoot "./Cache"
  224. </Object>
  225.  
  226. # ---
  227. #
  228. # AccessLogger
  229. #
  230. #    An instance of ExpressionLoggerClass configured to generate an 
  231. #    logfile
  232. #
  233. # ---
  234. <Object>
  235.     Name AccessLogger
  236.     Class ExpressionLoggerClass
  237.  
  238.     #
  239.     # Append
  240.     #
  241.     OpenMode "a"
  242.     #
  243.     # Line to log 
  244.     Expression "$A $h - [$t] \"$r\" $s $b$M"
  245. </Object>
  246.  
  247. # ---
  248. #
  249. # CachingProxy
  250. #
  251. # Sequence of handlers for HTTP Caching Proxy
  252. #
  253. # ---
  254. <Object>
  255.     Name CachingProxy
  256.     Class FlexibleHandlerClass
  257.     Init <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  258.     Headers <A HREF="/pidocs/Objects/HTTP.html#ReadRequestHeaders">ReadRequestHeaders</A>
  259.  
  260.     #
  261.     # Middle phases do not apply to a proxy request
  262.     #
  263.     HostMap <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  264.     Mapping <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  265.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  266.     CheckAuth <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  267.     CheckAccess <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  268.     CheckType <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  269.  
  270.     #
  271.     # Handle the request with the proxy handler the status is 0 
  272.     # (request was not previously handled).
  273.     # Otherwise fall through to the error case.
  274.     #
  275.     Handle Condition="&or(&cmp($s,0),&cmp($s,200))" HandleCachingProxy
  276.  
  277.     #
  278.     # If we got here an error occurred.
  279.     Handle <A HREF="/pidocs/Objects/HTTP.html#SendErrorMessage">SendErrorMessage</A> DefaultMessage="Fragment/500-gw.htm" 
  280.  
  281.     #
  282.     # Logging, uncomment to write an access log
  283. #    Log AccessLogger File="Logs/access.txt"
  284.  
  285.     Log <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  286. </Object>
  287.  
  288. # ---
  289. #
  290. # ProxyIOObject
  291. # IOObject for communicating with remote HTTP server. This uses
  292. #    the TCP/IP transport.
  293. #
  294. # ---
  295. <Object>
  296.     Name ProxyIOObject
  297.     Class TCPIPIOClass
  298.     Type Active
  299.     RecvTimeout 60
  300.     SendTimeout 60
  301. </Object>
  302.  
  303. # ---
  304. #
  305. # HTTPLogicObject
  306. #
  307. #     HTTP Logic object, dispatches requests to all other handlers
  308. #
  309. # ---
  310. <Object>
  311.     Name HTTPLogicObject
  312.     Class HTTPDispatcherClass
  313.     Handlers CachingProxy
  314.     KeepOpen On
  315.     ServerRoot ./../
  316.     ServerStamp Pi3Web/0.9b4
  317.     DefaultHost MainVirtualHostInformation
  318.     ErrorLogFile "Logs/error.txt"
  319.  
  320.     # Specifying a file for DebugLogFile effectively turns on debugging
  321. #    DebugLogFile "Logs/debug.txt"
  322.  
  323.     #
  324.     # The following to directives specify expressions to be logged
  325.     # before and after each handler execution respectively.
  326.     # The expression as given logs process/thread and handler context
  327.     # information indented to the nested handler level.
  328.     #
  329.     # Timing information is also given for performance tuning.
  330.     #
  331.     # This logging information is EXTREMELY verbose. Don't even
  332.     # think about using it in a production server
  333.     #
  334.     DebugBeforeHandler "[$P:$k] &align(,$X)&align(,$X) |--> $T \
  335. -------- &align($N,12) &align($R,12) $n \"$r\" $s"
  336.     DebugAfterHandler "[$P:$k] &align(,$X)&align(,$X) |<-- $T \
  337. &align($D,8) &align($N,12) &align($R,12) $n \"$r\" $s"
  338. </Object>
  339. </PRE></BODY></HTML>