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

  1. <HTML><TITLE>Internet.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. # Internet.pi3
  188. #
  189. #    Pi3 Configuration file for Internet server.
  190. #
  191. #    - Serve files only (see Devel.pi3 for <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A> and SSI support).
  192. #    - Bare bones functionality.
  193. #    - Use If-Modified-Since headers (<A HREF="/pidocs/Objects/HTTP.html#ConditionalGet">ConditionalGet</A> handler).
  194. #
  195. # ===
  196.  
  197. #
  198. # Load library definitions for classes used here.
  199. #
  200. include ../Conf/HTTP.cnf
  201. include ../Conf/Plugins.cnf
  202.  
  203. # ---
  204. #
  205. # Default
  206. #
  207. #    Handle initial phases of requests, typically before we have enough
  208. #    information to select different execution paths
  209. #
  210. # ---
  211. <Object>
  212.     Name Default
  213.     Class FlexibleHandlerClass
  214.     Init <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  215.     Headers <A HREF="/pidocs/Objects/HTTP.html#ReadRequestHeaders">ReadRequestHeaders</A>
  216.     HostMap <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  217.  
  218.     # Change virtual path based on error code from redirections
  219.     Mapping <A HREF="/pidocs/Objects/HTTP.html#MapToErrorDocument">MapToErrorDocument</A> \
  220.         IgnoreStatus="0 200" \
  221.         DefaultMessage="/errors/unknown.htm" \
  222.         301="/errors/301.htm" \
  223.         304="/errors/304.htm" \
  224.         400="/errors/400.htm" \
  225.         401="/errors/401.htm" \
  226.         403="/errors/403.htm" \
  227.         404="/errors/404.htm" \
  228.         500="/errors/500.htm" \
  229.         501="/errors/501.htm"
  230. #
  231. #    Uncomment this to map user directories that are prefixed with a tilda
  232. #    tilda (~), i.e.
  233. #
  234. #    /~jroy/hello.html --> /home/jroy/public_html/hello.html
  235. #
  236. #    Mapping <A HREF="/pidocs/Objects/Plugins.html#UserDirectory">UserDirectory</A> UserDirectoryRoot="/home/" \
  237. #        HTMLDirectory="/public_html"
  238.  
  239.     Mapping <A HREF="/pidocs/Objects/HTTP.html#PathMapper">PathMapper</A> From="/errors/" To="Fragment/" 
  240.     Mapping <A HREF="/pidocs/Objects/HTTP.html#PathMapper">PathMapper</A> From="/icons/" To="Icons/" 
  241.  
  242.     # Document root
  243.     Mapping <A HREF="/pidocs/Objects/HTTP.html#PathMapper">PathMapper</A> From="/" To="WebRoot/" 
  244.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#DirectoryExists">DirectoryExists</A> IndexFile="index.html" IndexFile="index.htm"
  245.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#RefuseFileByMask">RefuseFileByMask</A> AllowFileMask="EF" RefuseStatus=404
  246.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#RefuseFileByMask">RefuseFileByMask</A> AllowFileMask="F" RefuseStatus=403
  247.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  248.     CheckAuth <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  249.     CheckAccess <A HREF="/pidocs/Objects/HTTP.html#AccessByFile">AccessByFile</A> RequirePermissions="R"
  250.  
  251.     #
  252.     # Cause a '501 Not Implemented' Message for requests that
  253.     # are not 'GET' or 'HEAD', i.e.
  254.     #    if !( Method=='GET' || Method=='HEAD' ) 
  255.     #    then
  256.     #        set status = 501
  257.     #    endif
  258.     #
  259.     CheckType Condition="¬(&or(&cmpi($m,GET),&cmpi($m,HEAD)))" \
  260.         <A HREF="/pidocs/Objects/HTTP.html#StatusCode">StatusCode</A> StatusCode="501"
  261.     
  262.     # <A HREF="/pidocs/Objects/HTTP.html#ConditionalGet">ConditionalGet</A> sends back a '304 Not Modified' under the right
  263.     # circumstances include the presence of a client If-Modified-Since
  264.     # header
  265.     CheckType <A HREF="/pidocs/Objects/HTTP.html#ConditionalGet">ConditionalGet</A>
  266.  
  267.     CheckType <A HREF="/pidocs/Objects/HTTP.html#CheckForDirectory">CheckForDirectory</A> SetType="internal/x-directory"
  268.  
  269.     #
  270.     # Otherwise: Set the media type based on the file extension
  271.     #
  272.     CheckType <A HREF="/pidocs/Objects/HTTP.html#MIMETypeByExtension">MIMETypeByExtension</A> 
  273.  
  274.     #
  275.     # Return 'COMPLETED' so an internal error will not be raised
  276.     #
  277.     CheckType <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  278.  
  279.     #
  280.     # Most requests refer to a file, so put that first 
  281.     #
  282.     # Handle the request by sending a file if
  283.     #    The Media type of the resource does not match internal/* 
  284.     #
  285.     Handle Condition="¬(®exp('internal/*',$c))" <A HREF="/pidocs/Objects/HTTP.html#SendFile">SendFile</A>
  286.     Handle Condition="&cmp($c,internal/x-directory)" ListDirectory
  287.     Handle Condition="&cmp($c,internal/x-imagemap)" <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A>
  288.     Log <A HREF="/pidocs/Objects/HTTP.html#ExpressionLogger">ExpressionLogger</A> File="Logs/access.txt" OpenMode="a" \
  289.         Expression="$A $h - [$t] \"$r\" $s $b$M"
  290. </Object>
  291.  
  292. # ---
  293. #
  294. # HTTPLogicObject
  295. #
  296. #     HTTP Logic object, dispatches requests to all other handlers
  297. #
  298. # ---
  299. <Object>
  300.     Name HTTPLogicObject
  301.     Class HTTPDispatcherClass
  302.     Handlers Default
  303.     KeepOpen On
  304.     ServerRoot ./../
  305.     ServerStamp Pi3Web/0.9b4
  306.     DefaultHost MainVirtualHostInformation
  307.     MIMEFile "Fragment/Mime.typ"
  308.     DefaultMIMEType "application/octet-stream"
  309.     ErrorLogFile "Logs/error.txt"
  310.  
  311.     # see Features.pi3 or Devel.pi3 for debugging options
  312. #    DebugLogFile "Logs/debug.txt"
  313. </Object>
  314.  
  315. # --- 
  316. #
  317. # Directory listing with HTML tables
  318. #
  319. # ---- 
  320. <Object>
  321.     Name ListDirectory
  322.     Class DirectoryIndexClass
  323.     HeaderPattern "<HTML><TITLE>Index of %p</TITLE>\
  324. <BODY BACKGROUND="/icons/Pi3Tile.gif"\
  325. BGCOLOR="#FFFFFF">\
  326. <H2>Index of %p</H2>\n"
  327.     ListTop "<CENTER><TABLE CELLSPACING=0 CELLPADDING=0 WIDTH=100'%'>\
  328. <TR>\
  329. <TH NOWARP ALIGN=LEFT>\
  330. <IMG SRC="/icons/blank.gif" ALIGN=MIDDLE BORDER=NONE ALT="">\
  331. <TH NOWRAP ALIGN=LEFT>Name<BR><HR SIZE=1 NOSHADE>\
  332. <TH NOWRAP ALIGN=LEFT>Size<BR><HR SIZE=1 NOSHADE>\
  333. <TH NOWRAP ALIGN=LEFT>Last Modified<BR><HR SIZE=1 NOSHADE>\
  334. <TH NOWRAP ALIGN=LEFT>Description<BR><HR SIZE=1 NOSHADE>\n"
  335.     FilePattern "<TR>\
  336. <TD NOWRAP ALIGN=LEFT VALIGN=TOP>\
  337. <A HREF="%r"><IMG SRC="%i" BORDER=NONE ALIGN=MIDDLE ALT=""></A>\
  338. <TD NOWRAP ALIGN=LEFT VALIGN=TOP><A HREF="%r">&abbrev(%n,20,...)</A>\
  339. <TD NOWRAP ALIGN=LEFT VALIGN=TOP>%s<TD>%l\
  340. <TD NOWRAP ALIGN=LEFT VALIGN=TOP>&if(%d,%d,<I>%c</I>)\n"
  341.     ListBottom "</TABLE></CENTER>\n"
  342.     LastModifiedFormat "%d-%b-%y %H:%M"
  343.     Include "*"
  344.     MIMEIcon "text/html /icons/layout.gif"
  345.     MIMEIcon "text/x-code /icons/c.gif"
  346.     MIMEIcon "text/x-perl /icons/p.gif"
  347.     MIMEIcon "text/* /icons/text.gif"
  348.     MIMEIcon "internal/x-directory /icons/folder.gif"
  349.     MIMEIcon "audio/* /icons/sound2.gif"
  350.     MIMEIcon "image/* /icons/image2.gif"
  351.     MIMEIcon "application/x-uuencoded /icons/uuencoded.gif"
  352.     MIMEIcon "application/x-tar /icons/compressed.gif"
  353.     MIMEIcon "application/x-gzip /icons/compressed.gif"
  354.     MIMEIcon "application/x-sh /icons/script.gif"
  355.     MIMEIcon "application/* /icons/binary.gif"
  356.     MIMEIcon "x-world/x-vrml /icons/burst.gif"
  357.     MIMEIcon "*/* /icons/unknown.gif"
  358.     DescriptionFile ".desc"
  359.     SwapFileName ".. Parent Directory"
  360.     FooterPattern "<HR SIZE=1 NOSHADE>\
  361. Contact the hostmaster <A HREF="mailto:$a"<I>$a</I></A>.\
  362. </BODY></HTML>"
  363.     HeaderFile "HEADER"
  364.     FooterFile "README"
  365.     Exclude "."
  366.     Exclude "~*"
  367.     Exclude ".desc"
  368.     Exclude "README"
  369.     Exclude "HEADER"
  370.     Options " Name | AbbrevSize | RelPath | Icon | MIMEType "
  371. </Object>
  372. </PRE></BODY></HTML>