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

  1. <HTML><TITLE>Personal.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. # Personal.pi3
  189. #
  190. #    Small web server for a desktop platform. Set the number of
  191. #    processes low (2 or so) and number of threads about 5 or 6.
  192. #
  193. #    - Serves up documents one document root.
  194. #    - Server up server-side includes, image maps
  195. #        and standard <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A>
  196. #    - This configuration only writes an error logfile,
  197. #        not an access logfile
  198. #
  199. # ===
  200.  
  201. #
  202. # Load library definitions for classes used here.
  203. #
  204. include ../Conf/HTTP.cnf
  205. include ../Conf/Plugins.cnf
  206.  
  207. # ---
  208. #
  209. # CGIMapper
  210. #
  211. #    Instance of PathMapperClass to Map <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A> URLs
  212. #
  213. #    <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A> Scripts set PATH_INFO. 
  214. #
  215. # ---
  216. <Object>
  217.     Name CGIMapper
  218.     Class PathMapperClass
  219.     CaseSensitive "No"
  220.     #
  221.     # Subdirectories below the mapping directory should be put in path info
  222.     #
  223.     PathInfo "Yes"
  224.     #
  225.     # Set the 'ObjectMap' variable in the response DB if this map is
  226.     # successful
  227.     #
  228.     <A HREF="/pidocs/Objects/HTTP.html#Action">Action</A> "&dbreplace(response,string,ObjectMap,Scripts)"
  229. </Object>
  230.  
  231. # ---
  232. #
  233. # AccessLogger
  234. #
  235. #    An instance of ExpressionLoggerClass configured to generate an 
  236. #    logfile
  237. #
  238. # ---
  239. <Object>
  240.     Name AccessLogger
  241.     Class ExpressionLoggerClass
  242.  
  243.     #
  244.     # Append
  245.     #
  246.     OpenMode "a"
  247.     #
  248.     # Line to log 
  249.     Expression "$A $h - [$t] \"$r\" $s $b$M"
  250. </Object>
  251.  
  252. # ---
  253. #
  254. # Start
  255. #
  256. #    Handle initial phases of requests, typically before we have enough
  257. #    information to select different execution paths
  258. #
  259. # ---
  260. <Object>
  261.     Name Start
  262.     Class FlexibleHandlerClass
  263.     Init <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  264.     Headers <A HREF="/pidocs/Objects/HTTP.html#ReadRequestHeaders">ReadRequestHeaders</A>
  265.     HostMap <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  266.     Mapping <A HREF="/pidocs/Objects/HTTP.html#MapToErrorDocument">MapToErrorDocument</A> \
  267.         IgnoreStatus="0 200" \
  268.         DefaultMessage="/errors/unknown.htm" \
  269.         301="/errors/301.ssi" \
  270.         304="/errors/304.htm" \
  271.         400="/errors/400.htm" \
  272.         401="/errors/401.ssi" \
  273.         403="/errors/403.ssi" \
  274.         404="/errors/404.ssi" \
  275.         500="/errors/500.ssi" \
  276.         501="/errors/501.htm"
  277.     Mapping CGIMapper From="/cgi-bin/" To="cgi-bin/"
  278.     Mapping <A HREF="/pidocs/Objects/HTTP.html#PathMapper">PathMapper</A> From="/errors/" To="Fragment/" 
  279.     Mapping <A HREF="/pidocs/Objects/HTTP.html#PathMapper">PathMapper</A> From="/icons/" To="Icons/"
  280.     
  281.     # Document root 
  282.     Mapping <A HREF="/pidocs/Objects/HTTP.html#PathMapper">PathMapper</A> From="/" To="WebRoot/"
  283. </Object>
  284.  
  285. # ---
  286. #
  287. # Default
  288. #
  289. #    Handle requests that other handlers have passed up
  290. #
  291. # ---
  292. <Object>
  293.     Name Default
  294.     Class FlexibleHandlerClass
  295.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#DirectoryExists">DirectoryExists</A> IndexFile="index.html" IndexFile="index.htm"
  296.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#RefuseFileByMask">RefuseFileByMask</A> AllowFileMask="EF" RefuseStatus=404
  297.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#RefuseFileByMask">RefuseFileByMask</A> AllowFileMask="F" RefuseStatus=403
  298.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  299.     CheckAuth <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  300.     CheckAccess <A HREF="/pidocs/Objects/HTTP.html#AccessByFile">AccessByFile</A> RequirePermissions="R"
  301.  
  302.     #
  303.     # Cause a '501 Not Implemented' Message for requests that
  304.     # are not 'GET' or 'HEAD', i.e.
  305.     #    if !( Method=='GET' || Method=='HEAD' ) 
  306.     #    then
  307.     #        set status = 501
  308.     #    endif
  309.     #
  310.     CheckType Condition="¬(&or(&cmpi($m,GET),&cmpi($m,HEAD)))" \
  311.         <A HREF="/pidocs/Objects/HTTP.html#StatusCode">StatusCode</A> StatusCode="501"
  312.     CheckType <A HREF="/pidocs/Objects/HTTP.html#ConditionalGet">ConditionalGet</A>
  313.     CheckType <A HREF="/pidocs/Objects/HTTP.html#CheckForDirectory">CheckForDirectory</A> SetType="internal/x-directory"
  314.  
  315.     #
  316.     # Otherwise: Set the media type based on the file extension
  317.     #
  318.     CheckType <A HREF="/pidocs/Objects/HTTP.html#MIMETypeByExtension">MIMETypeByExtension</A> 
  319.  
  320.     #
  321.     # Return 'COMPLETED' so an internal error will not be raised
  322.     #
  323.     CheckType <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode="COMPLETED"
  324.  
  325.     Handle Condition="&cmp($c,internal/x-directory)" ListDirectory
  326.     Handle Condition="&cmp($c,internal/x-server-parsed-html)" <A HREF="/pidocs/Objects/HTTP.html#SendSSI">SendSSI</A> \
  327.         Exec=Yes ExecFileFixup="\
  328. /* exec file="" maps to Standard <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A> (Scripts) */\
  329. &dbreplace(response,string,ObjectMap,Scripts)\
  330. &dbreplace(response,rfc822,Content-Type,internal/x-cgi)"
  331.     Handle Condition="&cmp($c,internal/x-imagemap)" <A HREF="/pidocs/Objects/Plugins.html#ImageMap">ImageMap</A>
  332.     Handle <A HREF="/pidocs/Objects/HTTP.html#SendFile">SendFile</A>
  333.     Log AccessLogger File="Logs/access.txt"
  334.     Log <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  335.     Destroy <A HREF="/pidocs/Objects/HTTP.html#DeleteTemporaryFiles">DeleteTemporaryFiles</A>
  336. </Object>
  337.  
  338. # ---
  339. # Scripts
  340. #
  341. #    Handler sequences for resources which have mapped to <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A>
  342. #
  343. # ---
  344. <Object>
  345.     Name Scripts
  346.     Class FlexibleHandlerClass
  347.     Condition "&cmp(&dblookup(response,string,ObjectMap),Scripts)"
  348.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#RefuseFileByMask">RefuseFileByMask</A> AllowFileMask="EFD" RefuseStatus=404
  349.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#RefuseFileByMask">RefuseFileByMask</A> AllowFileMask="F" RefuseStatus=403
  350.     CheckPath <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  351.     CheckAccess <A HREF="/pidocs/Objects/HTTP.html#AccessByFile">AccessByFile</A> RequirePermissions="X"
  352.     CheckType <A HREF="/pidocs/Objects/HTTP.html#ReturnCode">ReturnCode</A> ReturnCode=COMPLETED
  353.     Handle StandardCGI
  354. </Object>
  355.  
  356. # ---
  357. #
  358. # HTTPLogicObject
  359. #
  360. #     HTTP Logic object, dispatches requests to all other handlers
  361. #
  362. # ---
  363. <Object>
  364.     Name HTTPLogicObject
  365.     Class HTTPDispatcherClass
  366.     Handlers Start Scripts Default
  367.     KeepOpen On
  368.     ServerRoot ./../
  369.     ServerStamp Pi3Web/0.9b4
  370.     DefaultHost MainVirtualHostInformation
  371.     MIMEFile "Fragment/Mime.typ"
  372.     DefaultMIMEType "application/octet-stream"
  373.     ErrorLogFile "Logs/error.txt"
  374. </Object>
  375.  
  376. # ---
  377. #
  378. # Directory listing with HTML tables
  379. #
  380. # ---
  381. <Object>
  382.     Name ListDirectory
  383.     Class DirectoryIndexClass
  384.     HeaderPattern "<HTML><TITLE>Index of %p</TITLE>\
  385. <BODY BACKGROUND="/icons/Pi3Tile.gif"\
  386. BGCOLOR="#FFFFFF">\
  387. <H2>Index of %p</H2>\n"
  388.     ListTop "<CENTER><TABLE CELLSPACING=0 CELLPADDING=0 WIDTH=100'%'>\
  389. <TR>\
  390. <TH NOWARP ALIGN=LEFT>\
  391. <IMG SRC="/icons/blank.gif" ALIGN=MIDDLE BORDER=NONE ALT="">\
  392. <TH NOWRAP ALIGN=LEFT>Name<BR><HR SIZE=1 NOSHADE>\
  393. <TH NOWRAP ALIGN=LEFT>Size<BR><HR SIZE=1 NOSHADE>\
  394. <TH NOWRAP ALIGN=LEFT>Last Modified<BR><HR SIZE=1 NOSHADE>\
  395. <TH NOWRAP ALIGN=LEFT>Description<BR><HR SIZE=1 NOSHADE>\n"
  396.     FilePattern "<TR>\
  397. <TD NOWRAP ALIGN=LEFT VALIGN=TOP>\
  398. <A HREF="%r"><IMG SRC="%i" BORDER=NONE ALIGN=MIDDLE ALT=""></A>\
  399. <TD NOWRAP ALIGN=LEFT VALIGN=TOP><A HREF="%r">&abbrev(%n,20,...)</A>\
  400. <TD NOWRAP ALIGN=LEFT VALIGN=TOP>%s<TD>%l\
  401. <TD NOWRAP ALIGN=LEFT VALIGN=TOP>&if(%d,%d,<I>%c</I>)\n"
  402.     ListBottom "</TABLE></CENTER>\n"
  403.     LastModifiedFormat "%d-%b-%y %H:%M"
  404.     Include "*"
  405.     MIMEIcon "text/html /icons/layout.gif"
  406.     MIMEIcon "text/x-code /icons/c.gif"
  407.     MIMEIcon "text/x-perl /icons/p.gif"
  408.     MIMEIcon "text/* /icons/text.gif"
  409.     MIMEIcon "internal/x-directory /icons/folder.gif"
  410.     MIMEIcon "audio/* /icons/sound2.gif"
  411.     MIMEIcon "image/* /icons/image2.gif"
  412.     MIMEIcon "application/x-uuencoded /icons/uuencoded.gif"
  413.     MIMEIcon "application/x-tar /icons/compressed.gif"
  414.     MIMEIcon "application/x-gzip /icons/compressed.gif"
  415.     MIMEIcon "application/x-sh /icons/script.gif"
  416.     MIMEIcon "application/* /icons/binary.gif"
  417.     MIMEIcon "x-world/x-vrml /icons/burst.gif"
  418.     MIMEIcon "*/* /icons/unknown.gif"
  419.     DescriptionFile ".desc"
  420.     SwapFileName ".. Parent Directory"
  421.     FooterPattern "<HR SIZE=1 NOSHADE>\
  422. Contact the hostmaster <A HREF="mailto:$a"<I>$a</I></A>.\
  423. </BODY></HTML>"
  424.     HeaderFile "HEADER"
  425.     FooterFile "README"
  426.     Exclude "."
  427.     Exclude "~*"
  428.     Exclude ".desc"
  429.     Exclude "README"
  430.     Exclude "HEADER"
  431.     Options " Name | AbbrevSize | RelPath | Icon | MIMEType "
  432. </Object>
  433.  
  434. # ---
  435. #
  436. # CGIFileIOObject
  437. #     
  438. #    IOObject used for communication between web browser and
  439. #    server.
  440. #
  441. # ---
  442. <Object>
  443.     Name CGIFileIOObject
  444.     Class PipeIOClass
  445.     ReadTimeout -1
  446.     WriteTimeout 10
  447.     NoYield "Read"
  448. </Object>
  449.  
  450. # ---
  451. #
  452. # StandardCGI
  453. #
  454. # Configuration for Standard <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A>
  455. #
  456. # ---
  457. <Object>
  458.     Name StandardCGI
  459.     Class CGIClass
  460.     
  461.     # Specify the IO object use to communicate with the <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A> program
  462.     FileIOObject CGIFileIOObject
  463.  
  464.     # Snoop IO objects can be instantiated in the IO chain with a line
  465.     # like this. They log all IO trafic. This is useful for debugging.
  466. #    FileIOObject SnoopIOObject IOObject="CGIFileIOObject" OutFile="cgi.dbg" 
  467.  
  468.     DefaultCommandLine "%p%q"
  469.     CommandLineByExt .bat="cmd.exe /c %p%q"
  470.     CommandLineByExt .cmd="cmd.exe /c %p%q"
  471.     CommandLineByExt .pl="perl %p%q"
  472.     IncludeParentsEnvironment Yes
  473.     EnvironmentSize 8192
  474.     
  475.     # These are the environment variables that are sent to the
  476.     # <A HREF="/pidocs/Objects/HTTP.html#CGI">CGI</A> program
  477.     Variable "AUTH_TYPE=$x"
  478.     Variable "CONTENT_LENGTH=$Y"
  479.     Variable "CONTENT_TYPE=$C"
  480.     Variable "HTTPS=$g"
  481.     Variable "&if($K,HTTPS_KEYSIZE=$K,)"
  482.     Variable "&if($K,HTTPS_SECRETKEYSIZE=$G,)"
  483.     Variable "GATEWAY_INTERFACE=CGI/1.1"
  484.     Variable "PATH_INFO=$I"
  485.     Variable "PATH_TRANSLATED=$Z"
  486.     Variable "QUERY_STRING=$q"
  487.     Variable "REMOTE_ADDR=$A"
  488.     Variable "REMOTE_HOST=$h"
  489.     Variable "REMOTE_IDENT=$i"
  490.     Variable "REMOTE_USER=$u"
  491.     Variable "REQUEST_METHOD=$m"
  492.     Variable "SCRIPT_NAME=$z"
  493.     Variable "SERVER_NAME=$v"
  494.     Variable "SERVER_PORT=&if($p,$p,&if($K,443,80))"
  495.     Variable "SERVER_PROTOCOL=$H"
  496.     Variable "SERVER_SOFTWARE=$S"
  497.     ExtraHeaders Yes
  498.     ExtraHeadersPrefix "HTTP_"
  499.     ExtraHeadersIgnore "Content-Type Content-Length"
  500.     SendCRLF Yes
  501. </Object>
  502. </PRE></BODY></HTML>